git-p4: add failing test for "git-p4: respect excluded paths when detecting branches"
[gitweb.git] / t / t6043-merge-rename-directories.sh
index 4a71f17edd69a2cb6962cf759aa6ad1b7604c2db..62c564707b9ff8a8e86b1f8d2d2e3919c36f1b5f 100755 (executable)
@@ -278,7 +278,7 @@ test_expect_success '1d-check: Directory renames cause a rename/rename(2to1) con
                git ls-files -u >out &&
                test_line_count = 2 out &&
                git ls-files -o >out &&
-               test_line_count = 3 out &&
+               test_line_count = 1 out &&
 
                git rev-parse >actual \
                        :0:x/b :0:x/c :0:x/d :0:x/e :0:x/m :0:x/n &&
@@ -293,15 +293,16 @@ test_expect_success '1d-check: Directory renames cause a rename/rename(2to1) con
                         A:y/wham  B:z/wham &&
                test_cmp expect actual &&
 
-               test_path_is_missing x/wham &&
-               test_path_is_file x/wham~HEAD &&
-               test_path_is_file x/wham~B^0 &&
-
-               git hash-object >actual \
-                       x/wham~HEAD x/wham~B^0 &&
-               git rev-parse >expect \
-                       A:y/wham    B:z/wham &&
-               test_cmp expect actual
+               # Test that the two-way merge in x/wham is as expected
+               git cat-file -p :2:x/wham >expect &&
+               git cat-file -p :3:x/wham >other &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       expect empty other &&
+               test_cmp expect x/wham
        )
 '
 
@@ -1077,7 +1078,7 @@ test_expect_success '5c-check: Transitive rename would cause rename/rename/renam
                git ls-files -u >out &&
                test_line_count = 6 out &&
                git ls-files -o >out &&
-               test_line_count = 3 out &&
+               test_line_count = 1 out &&
 
                git rev-parse >actual \
                        :0:y/b :0:y/c :0:y/e &&
@@ -1093,9 +1094,9 @@ test_expect_success '5c-check: Transitive rename would cause rename/rename/renam
                test_cmp expect actual &&
 
                git hash-object >actual \
-                       w/d~HEAD w/d~B^0 z/d &&
+                       z/d &&
                git rev-parse >expect \
-                       O:x/d    B:w/d   O:x/d &&
+                       O:x/d &&
                test_cmp expect actual &&
                test_path_is_missing x/d &&
                test_path_is_file y/d &&
@@ -1670,7 +1671,7 @@ test_expect_success '7b-check: rename/rename(2to1), but only due to transitive r
                git ls-files -u >out &&
                test_line_count = 2 out &&
                git ls-files -o >out &&
-               test_line_count = 3 out &&
+               test_line_count = 1 out &&
 
                git rev-parse >actual \
                        :0:y/b :0:y/c :2:y/d :3:y/d &&
@@ -1678,15 +1679,16 @@ test_expect_success '7b-check: rename/rename(2to1), but only due to transitive r
                         O:z/b  O:z/c  O:w/d  O:x/d &&
                test_cmp expect actual &&
 
-               test_path_is_missing y/d &&
-               test_path_is_file y/d~HEAD &&
-               test_path_is_file y/d~B^0 &&
-
-               git hash-object >actual \
-                       y/d~HEAD y/d~B^0 &&
-               git rev-parse >expect \
-                       O:w/d    O:x/d &&
-               test_cmp expect actual
+               # Test that the two-way merge in y/d is as expected
+               git cat-file -p :2:y/d >expect &&
+               git cat-file -p :3:y/d >other &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       expect empty other &&
+               test_cmp expect y/d
        )
 '
 
@@ -3161,11 +3163,48 @@ test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2)
        )
 '
 
+test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2), other direction' '
+       (
+               cd 10c &&
+
+               git reset --hard &&
+               git clean -fdqx &&
+
+               git checkout B^0 &&
+               mkdir y &&
+               echo important >y/c &&
+
+               test_must_fail git merge -s recursive A^0 >out 2>err &&
+               test_i18ngrep "CONFLICT (rename/rename)" out &&
+               test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out &&
+
+               git ls-files -s >out &&
+               test_line_count = 6 out &&
+               git ls-files -u >out &&
+               test_line_count = 3 out &&
+               git ls-files -o >out &&
+               test_line_count = 3 out &&
+
+               git rev-parse >actual \
+                       :0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c &&
+               git rev-parse >expect \
+                        O:z/a  O:z/b  O:x/d  O:x/c  O:x/c  O:x/c &&
+               test_cmp expect actual &&
+
+               git hash-object y/c~HEAD >actual &&
+               git rev-parse O:x/c >expect &&
+               test_cmp expect actual &&
+
+               echo important >expect &&
+               test_cmp expect y/c
+       )
+'
+
 # Testcase 10d, Delete untracked w/ dir rename/rename(2to1)
 #   Commit O: z/{a,b,c_1},        x/{d,e,f_2}
 #   Commit A: y/{a,b},            x/{d,e,f_2,wham_1} + untracked y/wham
 #   Commit B: z/{a,b,c_1,wham_2}, y/{d,e}
-#   Expected: Failed Merge; y/{a,b,d,e} + untracked y/{wham,wham~B^0,wham~HEAD}+
+#   Expected: Failed Merge; y/{a,b,d,e} + untracked y/{wham,wham~merged}+
 #             CONFLICT(rename/rename) z/c_1 vs x/f_2 -> y/wham
 #             ERROR_MSG(Refusing to lose untracked file at y/wham)
 
@@ -3219,7 +3258,7 @@ test_expect_success '10d-check: Delete untracked with dir rename/rename(2to1)' '
                git ls-files -u >out &&
                test_line_count = 2 out &&
                git ls-files -o >out &&
-               test_line_count = 4 out &&
+               test_line_count = 3 out &&
 
                git rev-parse >actual \
                        :0:y/a :0:y/b :0:y/d :0:y/e :2:y/wham :3:y/wham &&
@@ -3232,11 +3271,16 @@ test_expect_success '10d-check: Delete untracked with dir rename/rename(2to1)' '
                echo important >expect &&
                test_cmp expect y/wham &&
 
-               git hash-object >actual \
-                       y/wham~B^0 y/wham~HEAD &&
-               git rev-parse >expect \
-                       O:x/f      O:z/c &&
-               test_cmp expect actual
+               # Test that the two-way merge in y/wham~merged is as expected
+               git cat-file -p :2:y/wham >expect &&
+               git cat-file -p :3:y/wham >other &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       expect empty other &&
+               test_cmp expect y/wham~merged
        )
 '
 
@@ -3665,7 +3709,7 @@ test_expect_success '11e-check: Avoid deleting not-uptodate with dir rename/rena
                git ls-files -u >out &&
                test_line_count = 4 out &&
                git ls-files -o >out &&
-               test_line_count = 4 out &&
+               test_line_count = 3 out &&
 
                echo different >expected &&
                echo mods >>expected &&
@@ -3677,11 +3721,17 @@ test_expect_success '11e-check: Avoid deleting not-uptodate with dir rename/rena
                         O:z/a  O:z/b  O:x/d  O:x/c  O:x/c  A:y/c  O:x/c &&
                test_cmp expect actual &&
 
-               git hash-object >actual \
-                       y/c~B^0 y/c~HEAD &&
-               git rev-parse >expect \
-                       O:x/c   A:y/c &&
-               test_cmp expect actual
+               # See if y/c~merged has expected contents; requires manually
+               # doing the expected file merge
+               git cat-file -p A:y/c >c1 &&
+               git cat-file -p B:z/c >c2 &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       c1 empty c2 &&
+               test_cmp c1 y/c~merged
        )
 '
 
@@ -3689,7 +3739,7 @@ test_expect_success '11e-check: Avoid deleting not-uptodate with dir rename/rena
 #   Commit O: z/{a,b},        x/{c_1,d_2}
 #   Commit A: y/{a,b,wham_1}, x/d_2, except y/wham has uncommitted mods
 #   Commit B: z/{a,b,wham_2}, x/c_1
-#   Expected: Failed Merge; y/{a,b} + untracked y/{wham~B^0,wham~B^HEAD} +
+#   Expected: Failed Merge; y/{a,b} + untracked y/{wham~merged} +
 #             y/wham with dirty changes from before merge +
 #             CONFLICT(rename/rename) x/c vs x/d -> y/wham
 #             ERROR_MSG(Refusing to lose dirty file at y/wham)
@@ -3741,24 +3791,30 @@ test_expect_success '11f-check: Avoid deleting not-uptodate with dir rename/rena
                git ls-files -u >out &&
                test_line_count = 2 out &&
                git ls-files -o >out &&
-               test_line_count = 4 out &&
+               test_line_count = 3 out &&
 
                test_seq 1 10 >expected &&
                echo important >>expected &&
                test_cmp expected y/wham &&
 
                test_must_fail git rev-parse :1:y/wham &&
-               git hash-object >actual \
-                       y/wham~B^0 y/wham~HEAD &&
-               git rev-parse >expect \
-                       O:x/d      O:x/c &&
-               test_cmp expect actual &&
 
                git rev-parse >actual \
                        :0:y/a :0:y/b :2:y/wham :3:y/wham &&
                git rev-parse >expect \
                         O:z/a  O:z/b  O:x/c     O:x/d &&
-               test_cmp expect actual
+               test_cmp expect actual &&
+
+               # Test that the two-way merge in y/wham~merged is as expected
+               git cat-file -p :2:y/wham >expect &&
+               git cat-file -p :3:y/wham >other &&
+               >empty &&
+               test_must_fail git merge-file \
+                       -L "HEAD" \
+                       -L "" \
+                       -L "B^0" \
+                       expect empty other &&
+               test_cmp expect y/wham~merged
        )
 '