Skip to content

Commit 3e5261a

Browse files
author
Junio C Hamano
committed
merge-recursive: separate out xdl_merge() interface.
This just moves code around to make the actual call to xdl_merge() into a separate function. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 515106f commit 3e5261a

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

merge-recursive.c

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,39 @@ static void fill_mm(const unsigned char *sha1, mmfile_t *mm)
659659
mm->size = size;
660660
}
661661

662+
static int ll_merge(mmbuffer_t *result_buf,
663+
struct diff_filespec *o,
664+
struct diff_filespec *a,
665+
struct diff_filespec *b,
666+
const char *branch1,
667+
const char *branch2)
668+
{
669+
mmfile_t orig, src1, src2;
670+
xpparam_t xpp;
671+
char *name1, *name2;
672+
int merge_status;
673+
674+
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
675+
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
676+
677+
fill_mm(o->sha1, &orig);
678+
fill_mm(a->sha1, &src1);
679+
fill_mm(b->sha1, &src2);
680+
681+
memset(&xpp, 0, sizeof(xpp));
682+
merge_status = xdl_merge(&orig,
683+
&src1, name1,
684+
&src2, name2,
685+
&xpp, XDL_MERGE_ZEALOUS,
686+
result_buf);
687+
free(name1);
688+
free(name2);
689+
free(orig.ptr);
690+
free(src1.ptr);
691+
free(src2.ptr);
692+
return merge_status;
693+
}
694+
662695
static struct merge_file_info merge_file(struct diff_filespec *o,
663696
struct diff_filespec *a, struct diff_filespec *b,
664697
const char *branch1, const char *branch2)
@@ -687,30 +720,11 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
687720
else if (sha_eq(b->sha1, o->sha1))
688721
hashcpy(result.sha, a->sha1);
689722
else if (S_ISREG(a->mode)) {
690-
mmfile_t orig, src1, src2;
691723
mmbuffer_t result_buf;
692-
xpparam_t xpp;
693-
char *name1, *name2;
694724
int merge_status;
695725

696-
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
697-
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
698-
699-
fill_mm(o->sha1, &orig);
700-
fill_mm(a->sha1, &src1);
701-
fill_mm(b->sha1, &src2);
702-
703-
memset(&xpp, 0, sizeof(xpp));
704-
merge_status = xdl_merge(&orig,
705-
&src1, name1,
706-
&src2, name2,
707-
&xpp, XDL_MERGE_ZEALOUS,
708-
&result_buf);
709-
free(name1);
710-
free(name2);
711-
free(orig.ptr);
712-
free(src1.ptr);
713-
free(src2.ptr);
726+
merge_status = ll_merge(&result_buf, o, a, b,
727+
branch1, branch2);
714728

715729
if ((merge_status < 0) || !result_buf.ptr)
716730
die("Failed to execute internal merge");

0 commit comments

Comments
 (0)