Merge branch 'sg/fast-import-dump-refs-on-checkpoint-fix'
[gitweb.git] / t / t6042-merge-rename-corner-cases.sh
index 46e1aa7dfe2faa91e4f03fa2a8b359b293d81cdf..07dd09d985fad600c6f21d335ccfb30e3626db13 100755 (executable)
@@ -352,7 +352,7 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
                        base:file   left-conflict:newfile  right:file &&
                git rev-parse >actual                                 \
                        :1:newfile  :2:newfile             :3:newfile &&
-               test_cmp expect actual
+               test_cmp expect actual &&
 
                test_path_is_file newfile/realfile &&
                test_path_is_file newfile~HEAD
@@ -580,7 +580,7 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge'
                        C:a   A:a   B:b   C:C &&
                git rev-parse >actual          \
                        :3:a  :1:a  :2:b  :3:c &&
-               test_cmp expect actual
+               test_cmp expect actual &&
 
                test_path_is_file a &&
                test_path_is_file b &&
@@ -680,13 +680,13 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
                        A:a   C:b   B:b   C:c   B:c &&
                git rev-parse >actual                \
                        :1:a  :2:b  :3:b  :2:c  :3:c &&
-               test_cmp expect actual
+               test_cmp expect actual &&
 
                git rev-parse >expect               \
                        C:c     B:c     C:b     B:b &&
                git hash-object >actual                \
                        c~HEAD  c~B\^0  b~HEAD  b~B\^0 &&
-               test_cmp expect actual
+               test_cmp expect actual &&
 
                test_path_is_missing b &&
                test_path_is_missing c
@@ -827,4 +827,115 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
        )
 '
 
+# Testcase mod6, chains of rename/rename(1to2) and rename/rename(2to1)
+#   Commit O: one,      three,       five
+#   Commit A: one->two, three->four, five->six
+#   Commit B: one->six, three->two,  five->four
+#   Expected: six CONFLICT(rename/rename) messages, each path in two of the
+#             multi-way merged contents found in two, four, six
+
+test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename(2to1)' '
+       test_create_repo mod6 &&
+       (
+               cd mod6 &&
+               test_seq 11 19 >one &&
+               test_seq 31 39 >three &&
+               test_seq 51 59 >five &&
+               git add . &&
+               test_tick &&
+               git commit -m "O" &&
+
+               git branch O &&
+               git branch A &&
+               git branch B &&
+
+               git checkout A &&
+               test_seq 10 19 >one &&
+               echo 40        >>three &&
+               git add one three &&
+               git mv  one   two  &&
+               git mv  three four &&
+               git mv  five  six  &&
+               test_tick &&
+               git commit -m "A" &&
+
+               git checkout B &&
+               echo 20    >>one       &&
+               echo forty >>three     &&
+               echo 60    >>five      &&
+               git add one three five &&
+               git mv  one   six  &&
+               git mv  three two  &&
+               git mv  five  four &&
+               test_tick &&
+               git commit -m "B"
+       )
+'
+
+test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' '
+       (
+               cd mod6 &&
+
+               git checkout A^0 &&
+
+               test_must_fail git merge -s recursive B^0 >out 2>err &&
+
+               test_i18ngrep "CONFLICT (rename/rename)" out &&
+               test_must_be_empty err &&
+
+               git ls-files -s >file_count &&
+               test_line_count = 6 file_count &&
+               git ls-files -u >file_count &&
+               test_line_count = 6 file_count &&
+               git ls-files -o >file_count &&
+               test_line_count = 3 file_count &&
+
+               test_seq 10 20 >merged-one &&
+               test_seq 51 60 >merged-five &&
+               # Determine what the merge of three would give us.
+               test_seq 30 40 >three-side-A &&
+               test_seq 31 39 >three-side-B &&
+               echo forty >three-side-B &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       three-side-A empty three-side-B &&
+               sed -e "s/^\([<=>]\)/\1\1\1/" three-side-A >merged-three &&
+
+               # Verify the index is as expected
+               git rev-parse >actual         \
+                       :2:two       :3:two   \
+                       :2:four      :3:four  \
+                       :2:six       :3:six   &&
+               git hash-object >expect           \
+                       merged-one   merged-three \
+                       merged-three merged-five  \
+                       merged-five  merged-one   &&
+               test_cmp expect actual &&
+
+               git cat-file -p :2:two >expect &&
+               git cat-file -p :3:two >other &&
+               test_must_fail git merge-file    \
+                       -L "HEAD"  -L ""  -L "B^0" \
+                       expect     empty  other &&
+               test_cmp expect two &&
+
+               git cat-file -p :2:four >expect &&
+               git cat-file -p :3:four >other &&
+               test_must_fail git merge-file    \
+                       -L "HEAD"  -L ""  -L "B^0" \
+                       expect     empty  other &&
+               test_cmp expect four &&
+
+               git cat-file -p :2:six >expect &&
+               git cat-file -p :3:six >other &&
+               test_must_fail git merge-file    \
+                       -L "HEAD"  -L ""  -L "B^0" \
+                       expect     empty  other &&
+               test_cmp expect six
+       )
+'
+
 test_done