summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2011-08-11 23:20:09 -0600
committerJunio C Hamano <gitster@pobox.com>2011-08-14 14:19:37 -0700
commit3c217c077a86d9ae06ed26bb0baa4475d0e28a0e (patch)
tree9af76e87c3b3b100fdbf3aa96bda3808b2eb1c5c /merge-recursive.c
parent4f66dade81c2ebc6e1143b6c116960bfcd837067 (diff)
downloadgit-3c217c077a86d9ae06ed26bb0baa4475d0e28a0e.tar.gz
merge-recursive: Provide more info in conflict markers with file renames
Whenever there are merge conflicts in file contents, we would mark the different sides of the conflict with the two branches being merged. However, when there is a rename involved as well, the branchname is not sufficient to specify where the conflicting content came from. In such cases, mark the two sides of the conflict with branchname:filename rather than just branchname. 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.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index e68396bcb0..a3bbca8d58 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1353,6 +1353,7 @@ static int merge_content(struct merge_options *o,
struct rename_conflict_info *rename_conflict_info)
{
const char *reason = "content";
+ char *side1 = NULL, *side2 = NULL;
struct merge_file_info mfi;
struct diff_filespec one, a, b;
unsigned df_conflict_remains = 0;
@@ -1369,10 +1370,31 @@ static int merge_content(struct merge_options *o,
hashcpy(b.sha1, b_sha);
b.mode = b_mode;
- mfi = merge_file(o, &one, &a, &b, o->branch1, o->branch2);
- if (rename_conflict_info && dir_in_way(path, !o->call_depth)) {
- df_conflict_remains = 1;
+ if (rename_conflict_info) {
+ const char *path1, *path2;
+ struct diff_filepair *pair1 = rename_conflict_info->pair1;
+
+ path1 = (o->branch1 == rename_conflict_info->branch1) ?
+ pair1->two->path : pair1->one->path;
+ /* If rename_conflict_info->pair2 != NULL, we are in
+ * RENAME_ONE_FILE_TO_ONE case. Otherwise, we have a
+ * normal rename.
+ */
+ 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(o, &one, &a, &b,
+ side1 ? side1 : o->branch1, side2 ? side2 : o->branch2);
+ free(side1);
+ free(side2);
if (mfi.clean && !df_conflict_remains &&
sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode)