merge-recursive: mark rename/delete conflict as unmerged
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>
Johannes Schindelin committed
Dec 22, 2008 at 23:10 UTC
36e3b5eafe967cb721f5e2bbaa396f979b8ebd7c
2 files changed
+28
merge-recursive.c
+5
@@ -902,6 +902,11 @@ static int process_renames(struct merge_options *o,
902
ren1_src, ren1_dst, branch1,
903
branch2);
904
update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
905
+ update_stages(ren1_dst, NULL,
906
+ branch1 == o->branch1 ?
907
+ ren1->pair->two : NULL,
908
+ branch1 == o->branch1 ?
909
+ NULL : ren1->pair->two, 1);
910
} else if (!sha_eq(dst_other.sha1, null_sha1)) {
911
const char *new_path;
912
clean_merge = 0;
t/t6024-recursive-merge.sh
+23
@@ -97,4 +97,27 @@ test_expect_success 'refuse to merge binary files' '
97
merge.err
98
'
99
100
+test_expect_success 'mark rename/delete as unmerged' '
101
+
102
+ git reset --hard &&
103
+ git checkout -b delete &&
104
+ git rm a1 &&
105
+ test_tick &&
106
+ git commit -m delete &&
107
+ git checkout -b rename HEAD^ &&
108
+ git mv a1 a2
109
+ test_tick &&
110
+ git commit -m rename &&
111
+ test_must_fail git merge delete &&
112
+ test 1 = $(git ls-files --unmerged | wc -l) &&
113
+ git rev-parse --verify :2:a2 &&
114
+ test_must_fail git rev-parse --verify :3:a2 &&
115
+ git checkout -f delete &&
116
+ test_must_fail git merge rename &&
117
+ test 1 = $(git ls-files --unmerged | wc -l) &&
118
+ test_must_fail git rev-parse --verify :2:a2 &&
119
+ git rev-parse --verify :3:a2
120
+
121
+'
122
+
123
test_done