Skip to content

Commit 11d9ade

Browse files
newrengitster
authored andcommitted
t6042: add testcase covering rename/add/delete conflict type
If a file is renamed on one side of history, and the other side of history both deletes the original file and adds a new unrelated file in the way of the rename, then we have what I call a rename/add/delete conflict. Add a testcase covering this scenario. Reported-by: Robert Dailey <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e333175 commit 11d9ade

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,70 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
693693
)
694694
'
695695

696+
# Testcase rad, rename/add/delete
697+
# Commit O: foo
698+
# Commit A: rm foo, add different bar
699+
# Commit B: rename foo->bar
700+
# Expected: CONFLICT (rename/add/delete), two-way merged bar
701+
702+
test_expect_success 'rad-setup: rename/add/delete conflict' '
703+
test_create_repo rad &&
704+
(
705+
cd rad &&
706+
echo "original file" >foo &&
707+
git add foo &&
708+
git commit -m "original" &&
709+
710+
git branch O &&
711+
git branch A &&
712+
git branch B &&
713+
714+
git checkout A &&
715+
git rm foo &&
716+
echo "different file" >bar &&
717+
git add bar &&
718+
git commit -m "Remove foo, add bar" &&
719+
720+
git checkout B &&
721+
git mv foo bar &&
722+
git commit -m "rename foo to bar"
723+
)
724+
'
725+
726+
test_expect_failure 'rad-check: rename/add/delete conflict' '
727+
(
728+
cd rad &&
729+
730+
git checkout B^0 &&
731+
test_must_fail git merge -s recursive A^0 >out 2>err &&
732+
733+
# Not sure whether the output should contain just one
734+
# "CONFLICT (rename/add/delete)" line, or if it should break
735+
# it into a pair of "CONFLICT (rename/delete)" and
736+
# "CONFLICT (rename/add)"; allow for either.
737+
test_i18ngrep "CONFLICT (rename.*add)" out &&
738+
test_i18ngrep "CONFLICT (rename.*delete)" out &&
739+
test_must_be_empty err &&
740+
741+
git ls-files -s >file_count &&
742+
test_line_count = 2 file_count &&
743+
git ls-files -u >file_count &&
744+
test_line_count = 2 file_count &&
745+
git ls-files -o >file_count &&
746+
test_line_count = 2 file_count &&
747+
748+
git rev-parse >actual \
749+
:2:bar :3:bar &&
750+
git rev-parse >expect \
751+
B:bar A:bar &&
752+
753+
test_cmp file_is_missing foo &&
754+
# bar should have two-way merged contents of the different
755+
# versions of bar; check that content from both sides is
756+
# present.
757+
grep original bar &&
758+
grep different bar
759+
)
760+
'
761+
696762
test_done

0 commit comments

Comments
 (0)