]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t6423-merge-rename-directories.sh
Fix various issues found in comments
[thirdparty/git.git] / t / t6423-merge-rename-directories.sh
index 4ab133f489ca322a752599dc940e4c9c12461ad3..85d947dd275875eb60a3ebe24bfd8919b4c0577b 100755 (executable)
@@ -454,7 +454,7 @@ test_expect_success '1f: Split a directory into two other directories' '
 #   the directory renamed, but the files within it. (see 1b)
 #
 #   If renames split a directory into two or more others, the directory
-#   with the most renames, "wins" (see 1c).  However, see the testcases
+#   with the most renames, "wins" (see 1f).  However, see the testcases
 #   in section 2, plus testcases 3a and 4a.
 ###########################################################################
 
@@ -4797,7 +4797,7 @@ test_setup_12f () {
        )
 }
 
-test_expect_merge_algorithm failure success '12f: Trivial directory resolve, caching, all kinds of fun' '
+test_expect_merge_algorithm failure failure '12f: Trivial directory resolve, caching, all kinds of fun' '
        test_setup_12f &&
        (
                cd 12f &&
@@ -4895,6 +4895,135 @@ test_expect_merge_algorithm failure success '12f: Trivial directory resolve, cac
        )
 '
 
+# Testcase 12g, Testcase with two kinds of "relevant" renames
+#   Commit O: somefile_O, subdir/{a_O,b_O}
+#   Commit A: somefile_A, subdir/{a_O,b_O,c_A}
+#   Commit B: newfile_B,  newdir/{a_B,b_B}
+#   Expected: newfile_{merged}, newdir/{a_B,b_B,c_A}
+
+test_setup_12g () {
+       test_create_repo 12g &&
+       (
+               cd 12g &&
+
+               mkdir -p subdir &&
+               test_write_lines upon a time there was a >somefile &&
+               test_write_lines 1 2 3 4 5 6 7 8 9 10 >subdir/a &&
+               test_write_lines one two three four five six >subdir/b &&
+               git add . &&
+               test_tick &&
+               git commit -m "O" &&
+
+               git branch O &&
+               git branch A &&
+               git branch B &&
+
+               git switch A &&
+               test_write_lines once upon a time there was a >somefile &&
+               > subdir/c &&
+               git add somefile subdir/c &&
+               test_tick &&
+               git commit -m "A" &&
+
+               git checkout B &&
+               git mv somefile newfile &&
+               git mv subdir newdir &&
+               echo repo >>newfile &&
+               test_write_lines 1 2 3 4 5 6 7 8 9 10 11 >newdir/a &&
+               test_write_lines one two three four five six seven >newdir/b &&
+               git add newfile newdir &&
+               test_tick &&
+               git commit -m "B"
+       )
+}
+
+test_expect_success '12g: Testcase with two kinds of "relevant" renames' '
+       test_setup_12g &&
+       (
+               cd 12g &&
+
+               git checkout A^0 &&
+
+               git -c merge.directoryRenames=true merge -s recursive B^0 &&
+
+               test_write_lines once upon a time there was a repo >expect &&
+               test_cmp expect newfile &&
+
+               git ls-files -s >out &&
+               test_line_count = 4 out &&
+
+               git rev-parse >actual \
+                       HEAD:newdir/a  HEAD:newdir/b   HEAD:newdir/c &&
+               git rev-parse >expect \
+                       B:newdir/a     B:newdir/b      A:subdir/c &&
+               test_cmp expect actual &&
+
+               test_must_fail git rev-parse HEAD:subdir/a &&
+               test_must_fail git rev-parse HEAD:subdir/b &&
+               test_must_fail git rev-parse HEAD:subdir/c &&
+               test_path_is_missing subdir/ &&
+               test_path_is_file newdir/c
+       )
+'
+
+# Testcase 12h, Testcase with two kinds of "relevant" renames
+#   Commit O: olddir/{a_1, b}
+#   Commit A: newdir/{a_2, b}
+#   Commit B: olddir/{alpha_1, b}
+#   Expected: newdir/{alpha_2, b}
+
+test_setup_12h () {
+       test_create_repo 12h &&
+       (
+               cd 12h &&
+
+               mkdir olddir &&
+               test_seq 3 8 >olddir/a &&
+               >olddir/b &&
+               git add olddir &&
+               git commit -m orig &&
+
+               git branch O &&
+               git branch A &&
+               git branch B &&
+
+               git switch A &&
+               test_seq 3 10 >olddir/a &&
+               git add olddir/a &&
+               git mv olddir newdir &&
+               git commit -m A &&
+
+               git switch B &&
+
+               git mv olddir/a olddir/alpha &&
+               git commit -m B
+       )
+}
+
+test_expect_failure '12h: renaming a file within a renamed directory' '
+       test_setup_12h &&
+       (
+               cd 12h &&
+
+               git checkout A^0 &&
+
+               test_might_fail git -c merge.directoryRenames=true merge -s recursive B^0 &&
+
+               git ls-files >tracked &&
+               test_line_count = 2 tracked &&
+
+               test_path_is_missing olddir/a &&
+               test_path_is_file newdir/alpha &&
+               test_path_is_file newdir/b &&
+
+               git rev-parse >actual \
+                       HEAD:newdir/alpha  HEAD:newdir/b &&
+               git rev-parse >expect \
+                       A:newdir/a         O:oldir/b &&
+               test_cmp expect actual
+       )
+'
+
 ###########################################################################
 # SECTION 13: Checking informational and conflict messages
 #