summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-08-10 22:17:01 -0700
committerJunio C Hamano <gitster@pobox.com>2009-08-10 22:17:01 -0700
commit14468ab45bae83ad300f17f41fe8fd555329ee5e (patch)
tree0f6bcb7b16ac48757a3add8054f38ebe50819b0d /merge-recursive.c
parent9c5164032f4c25090e6139a202825febb830feea (diff)
parentc94736a27f89bfc268aed0de7264deecdc136a58 (diff)
downloadgit-14468ab45bae83ad300f17f41fe8fd555329ee5e.tar.gz
Merge branch 'jc/maint-merge-recursive-fix'
* jc/maint-merge-recursive-fix: merge-recursive: don't segfault while handling rename clashes
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 d415c4188d..10d7913b06 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -952,9 +952,31 @@ static int process_renames(struct merge_options *o,
"%s added in %s",
ren1_src, ren1_dst, branch1,
ren1_dst, branch2);
- new_path = unique_path(o, ren1_dst, branch2);
- output(o, 1, "Adding as %s instead", new_path);
- update_file(o, 0, dst_other.sha1, dst_other.mode, new_path);
+ if (o->call_depth) {
+ struct merge_file_info mfi;
+ struct diff_filespec one, a, b;
+
+ one.path = a.path = b.path =
+ (char *)ren1_dst;
+ hashcpy(one.sha1, null_sha1);
+ one.mode = 0;
+ hashcpy(a.sha1, ren1->pair->two->sha1);
+ a.mode = ren1->pair->two->mode;
+ hashcpy(b.sha1, dst_other.sha1);
+ b.mode = dst_other.mode;
+ mfi = merge_file(o, &one, &a, &b,
+ branch1,
+ branch2);
+ output(o, 1, "Adding merged %s", ren1_dst);
+ update_file(o, 0,
+ mfi.sha,
+ mfi.mode,
+ ren1_dst);
+ } else {
+ new_path = unique_path(o, ren1_dst, branch2);
+ output(o, 1, "Adding as %s instead", new_path);
+ update_file(o, 0, dst_other.sha1, dst_other.mode, new_path);
+ }
} else if ((item = string_list_lookup(ren1_dst, renames2Dst))) {
ren2 = item->util;
clean_merge = 0;