3 test_description
="recursive merge corner cases w/ renames but not criss-crosses"
4 # t6036 has corner cases that involve both criss-cross merges and renames
7 .
"$TEST_DIRECTORY"/lib-merge.sh
9 test_setup_rename_delete_untracked
() {
10 test_create_repo rename-delete-untracked
&&
12 cd rename-delete-untracked
&&
14 echo "A pretty inscription" >ring
&&
17 git commit
-m beginning
&&
20 git checkout
-b rename-the-ring
&&
21 git
mv ring one-ring-to-rule-them-all
&&
23 git commit
-m fullname
&&
25 git checkout people
&&
30 git commit
-m track-people-instead-of-objects
&&
31 echo "Myyy PRECIOUSSS" >ring
35 test_expect_success
"Does git preserve Gollum's precious artifact?" '
36 test_setup_rename_delete_untracked &&
38 cd rename-delete-untracked &&
40 test_must_fail git merge -s recursive rename-the-ring &&
42 # Make sure git did not delete an untracked file
43 test_path_is_file ring
47 # Testcase setup for rename/modify/add-source:
48 # Commit A: new file: a
49 # Commit B: modify a slightly
50 # Commit C: rename a->b, add completely different a
52 # We should be able to merge B & C cleanly
54 test_setup_rename_modify_add_source
() {
55 test_create_repo rename-modify-add-source
&&
57 cd rename-modify-add-source
&&
59 printf "1\n2\n3\n4\n5\n6\n7\n" >a
&&
64 git checkout
-b B A
&&
69 git checkout
-b C A
&&
71 echo something completely different
>a
&&
77 test_expect_failure
'rename/modify/add-source conflict resolvable' '
78 test_setup_rename_modify_add_source &&
80 cd rename-modify-add-source &&
84 git merge -s recursive C^0 &&
86 git rev-parse >expect \
88 git rev-parse >actual \
90 test_cmp expect actual
94 test_setup_break_detection_1
() {
95 test_create_repo break-detection-1
&&
97 cd break-detection-1
&&
99 printf "1\n2\n3\n4\n5\n" >a
&&
105 git checkout
-b B A
&&
107 echo "Completely different content" >a
&&
111 git checkout
-b C A
&&
118 test_expect_failure
'conflict caused if rename not detected' '
119 test_setup_break_detection_1 &&
121 cd break-detection-1 &&
123 git checkout -q C^0 &&
124 git merge -s recursive B^0 &&
126 git ls-files -s >out &&
127 test_line_count = 3 out &&
128 git ls-files -u >out &&
129 test_line_count = 0 out &&
130 git ls-files -o >out &&
131 test_line_count = 1 out &&
133 test_line_count = 6 c &&
134 git rev-parse >expect \
136 git rev-parse >actual \
138 test_cmp expect actual
142 test_setup_break_detection_2
() {
143 test_create_repo break-detection-2
&&
145 cd break-detection-2
&&
147 printf "1\n2\n3\n4\n5\n" >a
&&
153 git checkout
-b D A
&&
157 echo "Completely different content" >a
&&
161 git checkout
-b E A
&&
163 echo "Completely different content" >>a
&&
169 test_expect_failure
'missed conflict if rename not detected' '
170 test_setup_break_detection_2 &&
172 cd break-detection-2 &&
174 git checkout -q E^0 &&
175 test_must_fail git merge -s recursive D^0
179 # Tests for undetected rename/add-source causing a file to erroneously be
180 # deleted (and for mishandled rename/rename(1to1) causing the same issue).
182 # This test uses a rename/rename(1to1)+add-source conflict (1to1 means the
183 # same file is renamed on both sides to the same thing; it should trigger
184 # the 1to2 logic, which it would do if the add-source didn't cause issues
185 # for git's rename detection):
186 # Commit A: new file: a
187 # Commit B: rename a->b
188 # Commit C: rename a->b, add unrelated a
190 test_setup_break_detection_3
() {
191 test_create_repo break-detection-3
&&
193 cd break-detection-3
&&
195 printf "1\n2\n3\n4\n5\n" >a
&&
200 git checkout
-b B A
&&
204 git checkout
-b C A
&&
212 test_expect_failure
'detect rename/add-source and preserve all data' '
213 test_setup_break_detection_3 &&
215 cd break-detection-3 &&
219 git merge -s recursive C^0 &&
221 git ls-files -s >out &&
222 test_line_count = 2 out &&
223 git ls-files -u >out &&
224 test_line_count = 2 out &&
225 git ls-files -o >out &&
226 test_line_count = 1 out &&
228 test_path_is_file a &&
229 test_path_is_file b &&
231 git rev-parse >expect \
233 git rev-parse >actual \
235 test_cmp expect actual
239 test_expect_failure
'detect rename/add-source and preserve all data, merge other way' '
240 test_setup_break_detection_3 &&
242 cd break-detection-3 &&
246 git merge -s recursive B^0 &&
248 git ls-files -s >out &&
249 test_line_count = 2 out &&
250 git ls-files -u >out &&
251 test_line_count = 2 out &&
252 git ls-files -o >out &&
253 test_line_count = 1 out &&
255 test_path_is_file a &&
256 test_path_is_file b &&
258 git rev-parse >expect \
260 git rev-parse >actual \
262 test_cmp expect actual
266 test_setup_rename_directory
() {
267 test_create_repo rename-directory-
$1 &&
269 cd rename-directory-
$1 &&
271 printf "1\n2\n3\n4\n5\n6\n" >file &&
274 git commit
-m base
&&
277 git checkout
-b right
&&
280 echo junk
>newfile
/realfile
&&
281 git add
file newfile
/realfile
&&
283 git commit
-m right
&&
285 git checkout
-b left-conflict base
&&
288 git
mv file newfile
&&
290 git commit
-m left
&&
292 git checkout
-b left-clean base
&&
294 cat file >>newfile
&&
302 test_expect_success
'rename/directory conflict + clean content merge' '
303 test_setup_rename_directory 1a &&
305 cd rename-directory-1a &&
307 git checkout left-clean^0 &&
309 test_must_fail git merge -s recursive right^0 &&
311 git ls-files -s >out &&
312 test_line_count = 2 out &&
313 git ls-files -u >out &&
314 test_line_count = 1 out &&
315 git ls-files -o >out &&
316 test_line_count = 2 out &&
319 git cat-file -p base:file >>expect &&
321 test_cmp expect newfile~HEAD &&
323 test $(git rev-parse :2:newfile) = $(git hash-object expect) &&
325 test_path_is_file newfile/realfile &&
326 test_path_is_file newfile~HEAD
330 test_expect_success
'rename/directory conflict + content merge conflict' '
331 test_setup_rename_directory 1b &&
333 cd rename-directory-1b &&
338 git checkout left-conflict^0 &&
340 test_must_fail git merge -s recursive right^0 &&
342 git ls-files -s >out &&
343 test_line_count = 4 out &&
344 git ls-files -u >out &&
345 test_line_count = 3 out &&
346 git ls-files -o >out &&
347 test_line_count = 2 out &&
349 git cat-file -p left-conflict:newfile >left &&
350 git cat-file -p base:file >base &&
351 git cat-file -p right:file >right &&
352 test_must_fail git merge-file \
357 test_cmp left newfile~HEAD &&
359 git rev-parse >expect \
360 base:file left-conflict:newfile right:file &&
361 git rev-parse >actual \
362 :1:newfile :2:newfile :3:newfile &&
363 test_cmp expect actual &&
365 test_path_is_file newfile/realfile &&
366 test_path_is_file newfile~HEAD
370 test_setup_rename_directory_2
() {
371 test_create_repo rename-directory-2
&&
373 cd rename-directory-2
&&
376 printf "1\n2\n3\n4\n5\n6\n" >sub
/file &&
379 git commit
-m base
&&
382 git checkout
-b right
&&
386 git commit
-m right
&&
388 git checkout
-b left base
&&
390 cat sub
/file >>newfile
&&
399 test_expect_success
'disappearing dir in rename/directory conflict handled' '
400 test_setup_rename_directory_2 &&
402 cd rename-directory-2 &&
404 git checkout left^0 &&
406 git merge -s recursive right^0 &&
408 git ls-files -s >out &&
409 test_line_count = 1 out &&
410 git ls-files -u >out &&
411 test_line_count = 0 out &&
412 git ls-files -o >out &&
413 test_line_count = 1 out &&
416 git cat-file -p base:sub/file >>expect &&
418 test_cmp expect sub &&
420 test_path_is_file sub
424 # Test for basic rename/add-dest conflict, with rename needing content merge:
426 # Commit A: rename a->b, modifying b too
427 # Commit B: modify a, add different b
429 test_setup_rename_with_content_merge_and_add
() {
430 test_create_repo rename-with-content-merge-and-add-
$1 &&
432 cd rename-with-content-merge-and-add-
$1 &&
439 git checkout
-b A O
&&
445 git checkout
-b B O
&&
447 echo hello world
>b
&&
453 test_expect_success
'handle rename-with-content-merge vs. add' '
454 test_setup_rename_with_content_merge_and_add AB &&
456 cd rename-with-content-merge-and-add-AB &&
460 test_must_fail git merge -s recursive B^0 >out &&
461 test_i18ngrep "CONFLICT (.*/add)" out &&
463 git ls-files -s >out &&
464 test_line_count = 2 out &&
465 git ls-files -u >out &&
466 test_line_count = 2 out &&
467 # Also, make sure both unmerged entries are for "b"
468 git ls-files -u b >out &&
469 test_line_count = 2 out &&
470 git ls-files -o >out &&
471 test_line_count = 1 out &&
473 test_path_is_missing a &&
474 test_path_is_file b &&
477 git hash-object tmp >expect &&
478 git rev-parse B:b >>expect &&
479 git rev-parse >actual \
481 test_cmp expect actual &&
483 # Test that the two-way merge in b is as expected
484 git cat-file -p :2:b >>ours &&
485 git cat-file -p :3:b >>theirs &&
487 test_must_fail git merge-file \
496 test_expect_success
'handle rename-with-content-merge vs. add, merge other way' '
497 test_setup_rename_with_content_merge_and_add BA &&
499 cd rename-with-content-merge-and-add-BA &&
506 test_must_fail git merge -s recursive A^0 >out &&
507 test_i18ngrep "CONFLICT (.*/add)" out &&
509 git ls-files -s >out &&
510 test_line_count = 2 out &&
511 git ls-files -u >out &&
512 test_line_count = 2 out &&
513 # Also, make sure both unmerged entries are for "b"
514 git ls-files -u b >out &&
515 test_line_count = 2 out &&
516 git ls-files -o >out &&
517 test_line_count = 1 out &&
519 test_path_is_missing a &&
520 test_path_is_file b &&
523 git rev-parse B:b >expect &&
524 git hash-object tmp >>expect &&
525 git rev-parse >actual \
527 test_cmp expect actual &&
529 # Test that the two-way merge in b is as expected
530 git cat-file -p :2:b >>ours &&
531 git cat-file -p :3:b >>theirs &&
533 test_must_fail git merge-file \
542 # Test for all kinds of things that can go wrong with rename/rename (2to1):
543 # Commit A: new files: a & b
544 # Commit B: rename a->c, modify b
545 # Commit C: rename b->c, modify a
547 # Merging of B & C should NOT be clean. Questions:
548 # * Both a & b should be removed by the merge; are they?
549 # * The two c's should contain modifications to a & b; do they?
550 # * The index should contain two files, both for c; does it?
551 # * The working copy should have two files, both of form c~<unique>; does it?
552 # * Nothing else should be present. Is anything?
554 test_setup_rename_rename_2to1
() {
555 test_create_repo rename-rename-2to1
&&
557 cd rename-rename-2to1
&&
559 printf "1\n2\n3\n4\n5\n" >a
&&
560 printf "5\n4\n3\n2\n1\n" >b
&&
565 git checkout
-b B A
&&
571 git checkout
-b C A
&&
579 test_expect_success
'handle rename/rename (2to1) conflict correctly' '
580 test_setup_rename_rename_2to1 &&
582 cd rename-rename-2to1 &&
586 test_must_fail git merge -s recursive C^0 >out &&
587 test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
589 git ls-files -s >out &&
590 test_line_count = 2 out &&
591 git ls-files -u >out &&
592 test_line_count = 2 out &&
593 git ls-files -u c >out &&
594 test_line_count = 2 out &&
595 git ls-files -o >out &&
596 test_line_count = 1 out &&
598 test_path_is_missing a &&
599 test_path_is_missing b &&
601 git rev-parse >expect \
603 git rev-parse >actual \
605 test_cmp expect actual &&
607 # Test that the two-way merge in new_a is as expected
608 git cat-file -p :2:c >>ours &&
609 git cat-file -p :3:c >>theirs &&
611 test_must_fail git merge-file \
616 git hash-object c >actual &&
617 git hash-object ours >expect &&
618 test_cmp expect actual
622 # Testcase setup for simple rename/rename (1to2) conflict:
623 # Commit A: new file: a
624 # Commit B: rename a->b
625 # Commit C: rename a->c
626 test_setup_rename_rename_1to2
() {
627 test_create_repo rename-rename-1to2
&&
629 cd rename-rename-1to2
&&
637 git checkout
-b B A
&&
642 git checkout
-b C A
&&
649 test_expect_success
'merge has correct working tree contents' '
650 test_setup_rename_rename_1to2 &&
652 cd rename-rename-1to2 &&
656 test_must_fail git merge -s recursive B^0 &&
658 git ls-files -s >out &&
659 test_line_count = 3 out &&
660 git ls-files -u >out &&
661 test_line_count = 3 out &&
662 git ls-files -o >out &&
663 test_line_count = 1 out &&
665 test_path_is_missing a &&
666 git rev-parse >expect \
669 git rev-parse >actual \
671 git hash-object >>actual \
673 test_cmp expect actual
677 # Testcase setup for rename/rename(1to2)/add-source conflict:
678 # Commit A: new file: a
679 # Commit B: rename a->b
680 # Commit C: rename a->c, add completely different a
682 # Merging of B & C should NOT be clean; there's a rename/rename conflict
684 test_setup_rename_rename_1to2_add_source_1
() {
685 test_create_repo rename-rename-1to2-add-source-1
&&
687 cd rename-rename-1to2-add-source-1
&&
689 printf "1\n2\n3\n4\n5\n6\n7\n" >a
&&
694 git checkout
-b B A
&&
698 git checkout
-b C A
&&
700 echo something completely different
>a
&&
706 test_expect_failure
'detect conflict with rename/rename(1to2)/add-source merge' '
707 test_setup_rename_rename_1to2_add_source_1 &&
709 cd rename-rename-1to2-add-source-1 &&
713 test_must_fail git merge -s recursive C^0 &&
715 git ls-files -s >out &&
716 test_line_count = 4 out &&
717 git ls-files -o >out &&
718 test_line_count = 1 out &&
720 git rev-parse >expect \
722 git rev-parse >actual \
723 :3:a :1:a :2:b :3:c &&
724 test_cmp expect actual &&
726 test_path_is_file a &&
727 test_path_is_file b &&
732 test_setup_rename_rename_1to2_add_source_2
() {
733 test_create_repo rename-rename-1to2-add-source-2
&&
735 cd rename-rename-1to2-add-source-2
&&
740 git commit
-m base
&&
743 git checkout
-b B A
&&
748 git checkout
-b C A
&&
750 echo important-info
>a
&&
757 test_expect_failure
'rename/rename/add-source still tracks new a file' '
758 test_setup_rename_rename_1to2_add_source_2 &&
760 cd rename-rename-1to2-add-source-2 &&
763 git merge -s recursive B^0 &&
765 git ls-files -s >out &&
766 test_line_count = 2 out &&
767 git ls-files -o >out &&
768 test_line_count = 1 out &&
770 git rev-parse >expect \
772 git rev-parse >actual \
774 test_cmp expect actual
778 test_setup_rename_rename_1to2_add_dest
() {
779 test_create_repo rename-rename-1to2-add-dest
&&
781 cd rename-rename-1to2-add-dest
&&
786 git commit
-m base
&&
789 git checkout
-b B A
&&
791 echo precious-data
>c
&&
796 git checkout
-b C A
&&
798 echo important-info
>b
&&
805 test_expect_success
'rename/rename/add-dest merge still knows about conflicting file versions' '
806 test_setup_rename_rename_1to2_add_dest &&
808 cd rename-rename-1to2-add-dest &&
811 test_must_fail git merge -s recursive B^0 &&
813 git ls-files -s >out &&
814 test_line_count = 5 out &&
815 git ls-files -u b >out &&
816 test_line_count = 2 out &&
817 git ls-files -u c >out &&
818 test_line_count = 2 out &&
819 git ls-files -o >out &&
820 test_line_count = 1 out &&
822 git rev-parse >expect \
823 A:a C:b B:b C:c B:c &&
824 git rev-parse >actual \
825 :1:a :2:b :3:b :2:c :3:c &&
826 test_cmp expect actual &&
828 # Record some contents for re-doing merges
829 git cat-file -p A:a >stuff &&
830 git cat-file -p C:b >important_info &&
831 git cat-file -p B:c >precious_data &&
834 # Test the merge in b
835 test_must_fail git merge-file \
839 important_info empty stuff &&
840 test_cmp important_info b &&
842 # Test the merge in c
843 test_must_fail git merge-file \
847 stuff empty precious_data &&
852 # Testcase rad, rename/add/delete
854 # Commit A: rm foo, add different bar
855 # Commit B: rename foo->bar
856 # Expected: CONFLICT (rename/add/delete), two-way merged bar
859 test_create_repo rad
&&
862 echo "original file" >foo
&&
864 git commit
-m "original" &&
872 echo "different file" >bar
&&
874 git commit
-m "Remove foo, add bar" &&
878 git commit
-m "rename foo to bar"
882 test_expect_merge_algorithm failure success
'rad-check: rename/add/delete conflict' '
888 test_must_fail git merge -s recursive A^0 >out 2>err &&
890 # Instead of requiring the output to contain one combined line
891 # CONFLICT (rename/add/delete)
892 # or perhaps two lines:
893 # CONFLICT (rename/add): new file collides with rename target
894 # CONFLICT (rename/delete): rename source removed on other side
895 # and instead of requiring "rename/add" instead of "add/add",
896 # be flexible in the type of console output message(s) reported
897 # for this particular case; we will be more stringent about the
898 # contents of the index and working directory.
899 test_i18ngrep "CONFLICT (.*/add)" out &&
900 test_i18ngrep "CONFLICT (rename.*/delete)" out &&
901 test_must_be_empty err &&
903 git ls-files -s >file_count &&
904 test_line_count = 2 file_count &&
905 git ls-files -u >file_count &&
906 test_line_count = 2 file_count &&
907 git ls-files -o >file_count &&
908 test_line_count = 3 file_count &&
910 git rev-parse >actual \
912 git rev-parse >expect \
915 test_path_is_missing foo &&
916 # bar should have two-way merged contents of the different
917 # versions of bar; check that content from both sides is
924 # Testcase rrdd, rename/rename(2to1)/delete/delete
926 # Commit A: rename foo->baz, rm bar
927 # Commit B: rename bar->baz, rm foo
928 # Expected: CONFLICT (rename/rename/delete/delete), two-way merged baz
931 test_create_repo rrdd
&&
946 git commit
-m "Rename foo, remove bar" &&
951 git commit
-m "Rename bar, remove foo"
955 test_expect_merge_algorithm failure success
'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
961 test_must_fail git merge -s recursive B^0 >out 2>err &&
963 # Instead of requiring the output to contain one combined line
964 # CONFLICT (rename/rename/delete/delete)
965 # or perhaps two lines:
966 # CONFLICT (rename/rename): ...
967 # CONFLICT (rename/delete): info about pair 1
968 # CONFLICT (rename/delete): info about pair 2
969 # and instead of requiring "rename/rename" instead of "add/add",
970 # be flexible in the type of console output message(s) reported
971 # for this particular case; we will be more stringent about the
972 # contents of the index and working directory.
973 test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
974 test_i18ngrep "CONFLICT (rename.*delete)" out &&
975 test_must_be_empty err &&
977 git ls-files -s >file_count &&
978 test_line_count = 2 file_count &&
979 git ls-files -u >file_count &&
980 test_line_count = 2 file_count &&
981 git ls-files -o >file_count &&
982 test_line_count = 3 file_count &&
984 git rev-parse >actual \
986 git rev-parse >expect \
989 test_path_is_missing foo &&
990 test_path_is_missing bar &&
991 # baz should have two-way merged contents of the original
992 # contents of foo and bar; check that content from both sides
999 # Testcase mod6, chains of rename/rename(1to2) and rename/rename(2to1)
1000 # Commit O: one, three, five
1001 # Commit A: one->two, three->four, five->six
1002 # Commit B: one->six, three->two, five->four
1003 # Expected: six CONFLICT(rename/rename) messages, each path in two of the
1004 # multi-way merged contents found in two, four, six
1006 test_setup_mod6
() {
1007 test_create_repo mod6
&&
1010 test_seq
11 19 >one
&&
1011 test_seq
31 39 >three
&&
1012 test_seq
51 59 >five
&&
1015 git commit
-m "O" &&
1022 test_seq
10 19 >one
&&
1024 git add one three
&&
1026 git
mv three four
&&
1029 git commit
-m "A" &&
1033 echo forty
>>three
&&
1035 git add one three five
&&
1044 test_expect_merge_algorithm failure success
'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' '
1051 test_must_fail git merge -s recursive B^0 >out 2>err &&
1053 test_i18ngrep "CONFLICT (rename/rename)" out &&
1054 test_must_be_empty err &&
1056 git ls-files -s >file_count &&
1057 test_line_count = 9 file_count &&
1058 git ls-files -u >file_count &&
1059 test_line_count = 9 file_count &&
1060 git ls-files -o >file_count &&
1061 test_line_count = 3 file_count &&
1063 test_seq 10 20 >merged-one &&
1064 test_seq 51 60 >merged-five &&
1065 # Determine what the merge of three would give us.
1066 test_seq 31 39 >three-base &&
1067 test_seq 31 40 >three-side-A &&
1068 test_seq 31 39 >three-side-B &&
1069 echo forty >>three-side-B &&
1070 test_must_fail git merge-file \
1074 three-side-A three-base three-side-B &&
1075 sed -e "s/^\([<=>]\)/\1\1/" three-side-A >merged-three &&
1077 # Verify the index is as expected
1078 git rev-parse >actual \
1082 git hash-object >expect \
1083 merged-one merged-three \
1084 merged-three merged-five \
1085 merged-five merged-one &&
1086 test_cmp expect actual &&
1088 git cat-file -p :2:two >expect &&
1089 git cat-file -p :3:two >other &&
1091 test_must_fail git merge-file \
1092 -L "HEAD" -L "" -L "B^0" \
1093 expect empty other &&
1094 test_cmp expect two &&
1096 git cat-file -p :2:four >expect &&
1097 git cat-file -p :3:four >other &&
1098 test_must_fail git merge-file \
1099 -L "HEAD" -L "" -L "B^0" \
1100 expect empty other &&
1101 test_cmp expect four &&
1103 git cat-file -p :2:six >expect &&
1104 git cat-file -p :3:six >other &&
1105 test_must_fail git merge-file \
1106 -L "HEAD" -L "" -L "B^0" \
1107 expect empty other &&
1112 test_conflicts_with_adds_and_renames
() {
1124 # Both L and R have files named 'three' which collide. Each of
1125 # the colliding files could have been involved in a rename, in
1126 # which case there was a file named 'one' or 'two' that was
1127 # modified on the opposite side of history and renamed into the
1128 # collision on this side of history.
1131 # 1) The index should contain both a stage 2 and stage 3 entry
1132 # for the colliding file. Does it?
1133 # 2) When renames are involved, the content merges are clean, so
1134 # the index should reflect the content merges, not merely the
1135 # version of the colliding file from the prior commit. Does
1137 # 3) There should be a file in the worktree named 'three'
1138 # containing the two-way merged contents of the content-merged
1139 # versions of 'three' from each of the two colliding
1140 # files. Is it present?
1141 # 4) There should not be any three~* files in the working
1143 test_setup_collision_conflict
() {
1144 #test_expect_success "setup simple $sideL/$sideR conflict" '
1145 test_create_repo simple_
${sideL}_
${sideR} &&
1147 cd simple_
${sideL}_
${sideR} &&
1149 # Create some related files now
1150 for i
in $
(test_seq
1 10)
1152 echo Random base content line
$i
1154 cp file_v1 file_v2
&&
1155 echo modification
>>file_v2
&&
1157 cp file_v1 file_v3
&&
1158 echo more stuff
>>file_v3
&&
1159 cp file_v3 file_v4
&&
1160 echo yet
more stuff
>>file_v4
&&
1162 # Use a tag to record both these files for simple
1163 # access, and clean out these untracked files
1164 git tag file_v1 $
(git hash-object
-w file_v1
) &&
1165 git tag file_v2 $
(git hash-object
-w file_v2
) &&
1166 git tag file_v3 $
(git hash-object
-w file_v3
) &&
1167 git tag file_v4 $
(git hash-object
-w file_v4
) &&
1170 # Setup original commit (or merge-base), consisting of
1171 # files named "one" and "two" if renames were involved.
1172 touch irrelevant_file
&&
1173 git add irrelevant_file
&&
1174 if [ $sideL = "rename" ]
1176 git show file_v1
>one
&&
1179 if [ $sideR = "rename" ]
1181 git show file_v3
>two
&&
1184 test_tick
&& git commit
-m initial
&&
1189 # Handle the left side
1191 if [ $sideL = "rename" ]
1195 git show file_v2
>three
&&
1198 if [ $sideR = "rename" ]
1200 git show file_v4
>two
&&
1203 test_tick
&& git commit
-m L
&&
1205 # Handle the right side
1207 if [ $sideL = "rename" ]
1209 git show file_v2
>one
&&
1212 if [ $sideR = "rename" ]
1216 git show file_v4
>three
&&
1219 test_tick
&& git commit
-m R
1224 test_expect_success
"check simple $sideL/$sideR conflict" '
1225 test_setup_collision_conflict &&
1227 cd simple_${sideL}_${sideR} &&
1231 # Merge must fail; there is a conflict
1232 test_must_fail git merge -s recursive R^0 &&
1234 # Make sure the index has the right number of entries
1235 git ls-files -s >out &&
1236 test_line_count = 3 out &&
1237 git ls-files -u >out &&
1238 test_line_count = 2 out &&
1239 # Ensure we have the correct number of untracked files
1240 git ls-files -o >out &&
1241 test_line_count = 1 out &&
1243 # Nothing should have touched irrelevant_file
1244 git rev-parse >actual \
1245 :0:irrelevant_file \
1248 git rev-parse >expected \
1249 master:irrelevant_file \
1252 test_cmp expected actual &&
1254 # Make sure we have the correct merged contents for
1256 git show file_v1 >expected &&
1257 cat <<-\EOF >>expected &&
1266 test_cmp expected three
1271 test_conflicts_with_adds_and_renames rename rename
1272 test_conflicts_with_adds_and_renames rename add
1273 test_conflicts_with_adds_and_renames add rename
1274 test_conflicts_with_adds_and_renames add add
1284 # master has two files, named 'one' and 'two'.
1285 # branches L and R both modify 'one', in conflicting ways.
1286 # branches L and R both modify 'two', in conflicting ways.
1287 # branch L also renames 'one' to 'three'.
1288 # branch R also renames 'two' to 'three'.
1290 # So, we have four different conflicting files that all end up at path
1292 test_setup_nested_conflicts_from_rename_rename
() {
1293 test_create_repo nested_conflicts_from_rename_rename
&&
1295 cd nested_conflicts_from_rename_rename
&&
1297 # Create some related files now
1298 for i
in $
(test_seq
1 10)
1300 echo Random base content line
$i
1303 cp file_v1 file_v2
&&
1304 cp file_v1 file_v3
&&
1305 cp file_v1 file_v4
&&
1306 cp file_v1 file_v5
&&
1307 cp file_v1 file_v6
&&
1309 echo one
>>file_v1
&&
1310 echo uno
>>file_v2
&&
1311 echo eins
>>file_v3
&&
1313 echo two
>>file_v4
&&
1314 echo dos
>>file_v5
&&
1315 echo zwei
>>file_v6
&&
1317 # Setup original commit (or merge-base), consisting of
1318 # files named "one" and "two".
1322 test_tick
&& git commit
-m english
&&
1327 # Handle the left side
1330 mv -f file_v2 three
&&
1331 mv -f file_v5 two
&&
1332 git add two three
&&
1333 test_tick
&& git commit
-m spanish
&&
1335 # Handle the right side
1338 mv -f file_v3 one
&&
1339 mv -f file_v6 three
&&
1340 git add one three
&&
1341 test_tick
&& git commit
-m german
1345 test_expect_success
'check nested conflicts from rename/rename(2to1)' '
1346 test_setup_nested_conflicts_from_rename_rename &&
1348 cd nested_conflicts_from_rename_rename &&
1352 # Merge must fail; there is a conflict
1353 test_must_fail git merge -s recursive R^0 &&
1355 # Make sure the index has the right number of entries
1356 git ls-files -s >out &&
1357 test_line_count = 2 out &&
1358 git ls-files -u >out &&
1359 test_line_count = 2 out &&
1360 # Ensure we have the correct number of untracked files
1361 git ls-files -o >out &&
1362 test_line_count = 1 out &&
1364 # Compare :2:three to expected values
1365 git cat-file -p master:one >base &&
1366 git cat-file -p L:three >ours &&
1367 git cat-file -p R:one >theirs &&
1368 test_must_fail git merge-file \
1369 -L "HEAD:three" -L "" -L "R^0:one" \
1371 sed -e "s/^\([<=>]\)/\1\1/" ours >L-three &&
1372 git cat-file -p :2:three >expect &&
1373 test_cmp expect L-three &&
1375 # Compare :2:three to expected values
1376 git cat-file -p master:two >base &&
1377 git cat-file -p L:two >ours &&
1378 git cat-file -p R:three >theirs &&
1379 test_must_fail git merge-file \
1380 -L "HEAD:two" -L "" -L "R^0:three" \
1382 sed -e "s/^\([<=>]\)/\1\1/" ours >R-three &&
1383 git cat-file -p :3:three >expect &&
1384 test_cmp expect R-three &&
1386 # Compare three to expected contents
1388 test_must_fail git merge-file \
1389 -L "HEAD" -L "" -L "R^0" \
1390 L-three empty R-three &&
1391 test_cmp three L-three
1395 # Testcase rename/rename(1to2) of a binary file
1399 # Expected: CONFLICT(rename/rename) message, three unstaged entries in the
1400 # index, and contents of orig-[AB] at path orig-[AB]
1401 test_setup_rename_rename_1_to_2_binary
() {
1402 test_create_repo rename_rename_1_to_2_binary
&&
1404 cd rename_rename_1_to_2_binary
&&
1406 echo '* binary' >.gitattributes
&&
1407 git add .gitattributes
&&
1409 test_seq
1 10 >orig
&&
1411 git commit
-m orig
&&
1417 git
mv orig orig-A
&&
1418 test_seq
1 11 >orig-A
&&
1420 git commit
-m orig-A
&&
1423 git
mv orig orig-B
&&
1424 test_seq
0 10 >orig-B
&&
1426 git commit
-m orig-B
1431 test_expect_success
'rename/rename(1to2) with a binary file' '
1432 test_setup_rename_rename_1_to_2_binary &&
1434 cd rename_rename_1_to_2_binary &&
1438 test_must_fail git merge -s recursive B^0 &&
1440 # Make sure the index has the right number of entries
1441 git ls-files -s >actual &&
1442 test_line_count = 4 actual &&
1444 git rev-parse A:orig-A B:orig-B >expect &&
1445 git hash-object orig-A orig-B >actual &&
1446 test_cmp expect actual