Code

merge-recursive: mark rename/delete conflict as unmerged
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Mon, 22 Dec 2008 22:10:20 +0000 (23:10 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Dec 2008 07:06:48 +0000 (23:06 -0800)
When a file was renamed in one branch, but deleted in the other, one
should expect the index to contain an unmerged entry, namely the
target of the rename.  Make it so.

Noticed by Constantine Plotnikov.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t6024-recursive-merge.sh

index a0c804c8171d021780680f11901680d4c7e89e0b..69e71522048a3eeb70a093ae3c17a225168e932b 100644 (file)
@@ -902,6 +902,11 @@ static int process_renames(struct merge_options *o,
                                       ren1_src, ren1_dst, branch1,
                                       branch2);
                                update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
+                               update_stages(ren1_dst, NULL,
+                                               branch1 == o->branch1 ?
+                                               ren1->pair->two : NULL,
+                                               branch1 == o->branch1 ?
+                                               NULL : ren1->pair->two, 1);
                        } else if (!sha_eq(dst_other.sha1, null_sha1)) {
                                const char *new_path;
                                clean_merge = 0;
index 802d0d06ebddec9db6e3a109e689b3974f1e0ff1..129fa3000c9543804b43e74e27eec523e328bb5c 100755 (executable)
@@ -97,4 +97,27 @@ test_expect_success 'refuse to merge binary files' '
                merge.err
 '
 
+test_expect_success 'mark rename/delete as unmerged' '
+
+       git reset --hard &&
+       git checkout -b delete &&
+       git rm a1 &&
+       test_tick &&
+       git commit -m delete &&
+       git checkout -b rename HEAD^ &&
+       git mv a1 a2
+       test_tick &&
+       git commit -m rename &&
+       test_must_fail git merge delete &&
+       test 1 = $(git ls-files --unmerged | wc -l) &&
+       git rev-parse --verify :2:a2 &&
+       test_must_fail git rev-parse --verify :3:a2 &&
+       git checkout -f delete &&
+       test_must_fail git merge rename &&
+       test 1 = $(git ls-files --unmerged | wc -l) &&
+       test_must_fail git rev-parse --verify :2:a2 &&
+       git rev-parse --verify :3:a2
+
+'
+
 test_done