Skip to content

Commit 651f7f3

Browse files
newrengitster
authored andcommitted
t6042: add testcase covering long chains of rename conflicts
Each rename is a lego: the source side could be connected to a delete or another rename, and the destination side could be connected to a rename or a conflicting add. Previous tests combined these to get e.g. rename/rename(1to2)/add/add, rename/rename(2to1)/delete/delete, and rename/add/delete. But we can also build bigger chains of conflicts. Add a testcase demonstrating this. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eee7338 commit 651f7f3

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

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

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,4 +827,115 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
827827
)
828828
'
829829

830+
# Testcase mod6, chains of rename/rename(1to2) and rename/rename(2to1)
831+
# Commit O: one, three, five
832+
# Commit A: one->two, three->four, five->six
833+
# Commit B: one->six, three->two, five->four
834+
# Expected: six CONFLICT(rename/rename) messages, each path in two of the
835+
# multi-way merged contents found in two, four, six
836+
837+
test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename(2to1)' '
838+
test_create_repo mod6 &&
839+
(
840+
cd mod6 &&
841+
test_seq 11 19 >one &&
842+
test_seq 31 39 >three &&
843+
test_seq 51 59 >five &&
844+
git add . &&
845+
test_tick &&
846+
git commit -m "O" &&
847+
848+
git branch O &&
849+
git branch A &&
850+
git branch B &&
851+
852+
git checkout A &&
853+
test_seq 10 19 >one &&
854+
echo 40 >>three &&
855+
git add one three &&
856+
git mv one two &&
857+
git mv three four &&
858+
git mv five six &&
859+
test_tick &&
860+
git commit -m "A" &&
861+
862+
git checkout B &&
863+
echo 20 >>one &&
864+
echo forty >>three &&
865+
echo 60 >>five &&
866+
git add one three five &&
867+
git mv one six &&
868+
git mv three two &&
869+
git mv five four &&
870+
test_tick &&
871+
git commit -m "B"
872+
)
873+
'
874+
875+
test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' '
876+
(
877+
cd mod6 &&
878+
879+
git checkout A^0 &&
880+
881+
test_must_fail git merge -s recursive B^0 >out 2>err &&
882+
883+
test_i18ngrep "CONFLICT (rename/rename)" out &&
884+
test_must_be_empty err &&
885+
886+
git ls-files -s >file_count &&
887+
test_line_count = 6 file_count &&
888+
git ls-files -u >file_count &&
889+
test_line_count = 6 file_count &&
890+
git ls-files -o >file_count &&
891+
test_line_count = 3 file_count &&
892+
893+
test_seq 10 20 >merged-one &&
894+
test_seq 51 60 >merged-five &&
895+
# Determine what the merge of three would give us.
896+
test_seq 30 40 >three-side-A &&
897+
test_seq 31 39 >three-side-B &&
898+
echo forty >three-side-B &&
899+
>empty &&
900+
test_must_fail git merge-file \
901+
-L "HEAD" \
902+
-L "" \
903+
-L "B^0" \
904+
three-side-A empty three-side-B &&
905+
sed -e "s/^\([<=>]\)/\1\1\1/" three-side-A >merged-three &&
906+
907+
# Verify the index is as expected
908+
git rev-parse >actual \
909+
:2:two :3:two \
910+
:2:four :3:four \
911+
:2:six :3:six &&
912+
git hash-object >expect \
913+
merged-one merged-three \
914+
merged-three merged-five \
915+
merged-five merged-one &&
916+
test_cmp expect actual &&
917+
918+
git cat-file -p :2:two >expect &&
919+
git cat-file -p :3:two >other &&
920+
test_must_fail git merge-file \
921+
-L "HEAD" -L "" -L "B^0" \
922+
expect empty other &&
923+
test_cmp expect two &&
924+
925+
git cat-file -p :2:four >expect &&
926+
git cat-file -p :3:four >other &&
927+
test_must_fail git merge-file \
928+
-L "HEAD" -L "" -L "B^0" \
929+
expect empty other &&
930+
test_cmp expect four &&
931+
932+
git cat-file -p :2:six >expect &&
933+
git cat-file -p :3:six >other &&
934+
test_must_fail git merge-file \
935+
-L "HEAD" -L "" -L "B^0" \
936+
expect empty other &&
937+
test_cmp expect six
938+
)
939+
'
940+
830941
test_done

0 commit comments

Comments
 (0)