summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2011-08-11 23:20:17 -0600
committerJunio C Hamano <gitster@pobox.com>2011-08-14 14:19:38 -0700
commitdac4741554e7672e69d1bc6b4f912cd16ad83b38 (patch)
treeb4526414eff4b7a67d6458e5321cdc04e4ea7f57 /merge-recursive.c
parent232c635f7e22acb2ddf526753fdcd3d3718afe99 (diff)
downloadgit-dac4741554e7672e69d1bc6b4f912cd16ad83b38.tar.gz
merge-recursive: Create function for merging with branchname:file markers
We want to be able to reuse the code to do a three-way file content merge and have the conflict markers use both branchname and filename. Split it out into a separate function. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 27714c5bd7..4ceb6aac88 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -942,6 +942,36 @@ static struct merge_file_info merge_file_1(struct merge_options *o,
return result;
}
+static struct merge_file_info
+merge_file_special_markers(struct merge_options *o,
+ const struct diff_filespec *one,
+ const struct diff_filespec *a,
+ const struct diff_filespec *b,
+ const char *branch1,
+ const char *filename1,
+ const char *branch2,
+ const char *filename2)
+{
+ char *side1 = NULL;
+ char *side2 = NULL;
+ struct merge_file_info mfi;
+
+ if (filename1) {
+ side1 = xmalloc(strlen(branch1) + strlen(filename1) + 2);
+ sprintf(side1, "%s:%s", branch1, filename1);
+ }
+ if (filename2) {
+ side2 = xmalloc(strlen(branch2) + strlen(filename2) + 2);
+ sprintf(side2, "%s:%s", branch2, filename2);
+ }
+
+ mfi = merge_file_1(o, one, a, b,
+ side1 ? side1 : branch1, side2 ? side2 : branch2);
+ free(side1);
+ free(side2);
+ return mfi;
+}
+
static struct merge_file_info merge_file(struct merge_options *o,
const char *path,
const unsigned char *o_sha, int o_mode,
@@ -1415,7 +1445,6 @@ static int merge_content(struct merge_options *o,
struct rename_conflict_info *rename_conflict_info)
{
const char *reason = "content";
- char *side1 = NULL, *side2 = NULL;
const char *path1 = NULL, *path2 = NULL;
struct merge_file_info mfi;
struct diff_filespec one, a, b;
@@ -1445,18 +1474,13 @@ static int merge_content(struct merge_options *o,
path2 = (rename_conflict_info->pair2 ||
o->branch2 == rename_conflict_info->branch1) ?
pair1->two->path : pair1->one->path;
- side1 = xmalloc(strlen(o->branch1) + strlen(path1) + 2);
- side2 = xmalloc(strlen(o->branch2) + strlen(path2) + 2);
- sprintf(side1, "%s:%s", o->branch1, path1);
- sprintf(side2, "%s:%s", o->branch2, path2);
if (dir_in_way(path, !o->call_depth))
df_conflict_remains = 1;
}
- mfi = merge_file_1(o, &one, &a, &b,
- side1 ? side1 : o->branch1, side2 ? side2 : o->branch2);
- free(side1);
- free(side2);
+ mfi = merge_file_special_markers(o, &one, &a, &b,
+ o->branch1, path1,
+ o->branch2, path2);
if (mfi.clean && !df_conflict_remains &&
sha_eq(mfi.sha, a_sha) && mfi.mode == a_mode) {