Skip to content

Commit eee7338

Browse files
newrengitster
authored andcommitted
t6042: add testcase covering rename/rename(2to1)/delete/delete conflict
If either side of a rename/rename(2to1) conflict is itself also involved in a rename/delete conflict, then the conflict is a little more complex; we can even have what I'd call a rename/rename(2to1)/delete/delete conflict. (In some ways, this is similar to a rename/rename(1to2)/add/add conflict, as added in commit 3672c97 ("merge-recursive: Fix working copy handling for rename/rename/add/add", 2011-08-11)). Add a testcase for such a conflict. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 11d9ade commit eee7338

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

t/t6042-merge-rename-corner-cases.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,4 +759,72 @@ test_expect_failure 'rad-check: rename/add/delete conflict' '
759759
)
760760
'
761761

762+
# Testcase rrdd, rename/rename(2to1)/delete/delete
763+
# Commit O: foo, bar
764+
# Commit A: rename foo->baz, rm bar
765+
# Commit B: rename bar->baz, rm foo
766+
# Expected: CONFLICT (rename/rename/delete/delete), two-way merged baz
767+
768+
test_expect_success 'rrdd-setup: rename/rename(2to1)/delete/delete conflict' '
769+
test_create_repo rrdd &&
770+
(
771+
cd rrdd &&
772+
echo foo >foo &&
773+
echo bar >bar &&
774+
git add foo bar &&
775+
git commit -m O &&
776+
777+
git branch O &&
778+
git branch A &&
779+
git branch B &&
780+
781+
git checkout A &&
782+
git mv foo baz &&
783+
git rm bar &&
784+
git commit -m "Rename foo, remove bar" &&
785+
786+
git checkout B &&
787+
git mv bar baz &&
788+
git rm foo &&
789+
git commit -m "Rename bar, remove foo"
790+
)
791+
'
792+
793+
test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
794+
(
795+
cd rrdd &&
796+
797+
git checkout A^0 &&
798+
test_must_fail git merge -s recursive B^0 >out 2>err &&
799+
800+
# Not sure whether the output should contain just one
801+
# "CONFLICT (rename/rename/delete/delete)" line, or if it
802+
# should break it into three: "CONFLICT (rename/rename)" and
803+
# two "CONFLICT (rename/delete)" lines; allow for either.
804+
test_i18ngrep "CONFLICT (rename/rename)" out &&
805+
test_i18ngrep "CONFLICT (rename.*delete)" out &&
806+
test_must_be_empty err &&
807+
808+
git ls-files -s >file_count &&
809+
test_line_count = 2 file_count &&
810+
git ls-files -u >file_count &&
811+
test_line_count = 2 file_count &&
812+
git ls-files -o >file_count &&
813+
test_line_count = 2 file_count &&
814+
815+
git rev-parse >actual \
816+
:2:baz :3:baz &&
817+
git rev-parse >expect \
818+
O:foo O:bar &&
819+
820+
test_cmp file_is_missing foo &&
821+
test_cmp file_is_missing bar &&
822+
# baz should have two-way merged contents of the original
823+
# contents of foo and bar; check that content from both sides
824+
# is present.
825+
grep foo baz &&
826+
grep bar baz
827+
)
828+
'
829+
762830
test_done

0 commit comments

Comments
 (0)