diff options
Diffstat (limited to 't/t6423-merge-rename-directories.sh')
-rwxr-xr-x | t/t6423-merge-rename-directories.sh | 447 |
1 files changed, 304 insertions, 143 deletions
diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh index 5b81a13..88d1cf2 100755 --- a/t/t6423-merge-rename-directories.sh +++ b/t/t6423-merge-rename-directories.sh @@ -40,7 +40,7 @@ test_description="recursive merge with directory renames" # Expected: y/{b,c,d,e/f} test_setup_1a () { - test_create_repo 1a && + git init 1a && ( cd 1a && @@ -106,7 +106,7 @@ test_expect_success '1a: Simple directory rename detection' ' # Expected: y/{b,c,d,e} test_setup_1b () { - test_create_repo 1b && + git init 1b && ( cd 1b && @@ -169,7 +169,7 @@ test_expect_success '1b: Merge a directory with another' ' # Expected: y/{b,c,d} (because x/d -> z/d -> y/d) test_setup_1c () { - test_create_repo 1c && + git init 1c && ( cd 1c && @@ -232,7 +232,7 @@ test_expect_success '1c: Transitive renaming' ' # y/wham_1 & z/wham_2 should too...giving us a conflict. test_setup_1d () { - test_create_repo 1d && + git init 1d && ( cd 1d && @@ -276,7 +276,7 @@ test_expect_success '1d: Directory renames cause a rename/rename(2to1) conflict' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (\(.*\)/\1)" out && + test_grep "CONFLICT (\(.*\)/\1)" out && git ls-files -s >out && test_line_count = 8 out && @@ -328,7 +328,7 @@ test_expect_success '1d: Directory renames cause a rename/rename(2to1) conflict' # Expected: y/{newb,newc,d} test_setup_1e () { - test_create_repo 1e && + git init 1e && ( cd 1e && @@ -387,7 +387,7 @@ test_expect_success '1e: Renamed directory, with all files being renamed too' ' # Expected: y/{b,c}, x/{d,e,f,g} test_setup_1f () { - test_create_repo 1f && + git init 1f && ( cd 1f && @@ -476,7 +476,7 @@ test_expect_success '1f: Split a directory into two other directories' ' # Commit B: z/{b,c,d} # Expected: y/b, w/c, z/d, with warning about z/ -> (y/ vs. w/) conflict test_setup_2a () { - test_create_repo 2a && + git init 2a && ( cd 2a && @@ -515,7 +515,7 @@ test_expect_success '2a: Directory split into two on one side, with equal number git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT.*directory rename split" out && + test_grep "CONFLICT.*directory rename split" out && git ls-files -s >out && test_line_count = 3 out && @@ -538,7 +538,7 @@ test_expect_success '2a: Directory split into two on one side, with equal number # Commit B: z/{b,c}, x/d # Expected: y/b, w/c, x/d; No warning about z/ -> (y/ vs. w/) conflict test_setup_2b () { - test_create_repo 2b && + git init 2b && ( cd 2b && @@ -591,7 +591,7 @@ test_expect_success '2b: Directory split into two on one side, with equal number git rev-parse >expect \ O:z/b O:z/c B:x/d && test_cmp expect actual && - test_i18ngrep ! "CONFLICT.*directory rename split" out + test_grep ! "CONFLICT.*directory rename split" out ) ' @@ -620,7 +620,7 @@ test_expect_success '2b: Directory split into two on one side, with equal number # Commit B: y/{b,c}, x/d # Expected: y/{b,c}, x/d test_setup_3a () { - test_create_repo 3a && + git init 3a && ( cd 3a && @@ -684,7 +684,7 @@ test_expect_success '3a: Avoid implicit rename if involved as source on other si # end up with CONFLICT:(z/d -> y/d vs. x/d vs. w/d), i.e. a # rename/rename/rename(1to3) conflict, which is just weird. test_setup_3b () { - test_create_repo 3b && + git init 3b && ( cd 3b && @@ -726,8 +726,8 @@ test_expect_success '3b: Avoid implicit rename if involved as source on current git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep CONFLICT.*rename/rename.*z/d.*x/d.*w/d out && - test_i18ngrep ! CONFLICT.*rename/rename.*y/d out && + test_grep CONFLICT.*rename/rename.*z/d.*x/d.*w/d out && + test_grep ! CONFLICT.*rename/rename.*y/d out && git ls-files -s >out && test_line_count = 5 out && @@ -807,7 +807,7 @@ test_expect_success '3b: Avoid implicit rename if involved as source on current # NOTE: Even though most files from z moved to y, we don't want f to follow. test_setup_4a () { - test_create_repo 4a && + git init 4a && ( cd 4a && @@ -896,7 +896,7 @@ test_expect_success '4a: Directory split, with original directory still present' # index. test_setup_5a () { - test_create_repo 5a && + git init 5a && ( cd 5a && @@ -938,7 +938,7 @@ test_expect_success '5a: Merge directories, other side adds files to original an git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT.*implicit dir rename" out && + test_grep "CONFLICT.*implicit dir rename" out && git ls-files -s >out && test_line_count = 6 out && @@ -971,7 +971,7 @@ test_expect_success '5a: Merge directories, other side adds files to original an # back to git behavior without the directory rename detection. test_setup_5b () { - test_create_repo 5b && + git init 5b && ( cd 5b && @@ -1013,7 +1013,7 @@ test_expect_success '5b: Rename/delete in order to get add/add/add conflict' ' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (add/add).* y/d" out && + test_grep "CONFLICT (add/add).* y/d" out && git ls-files -s >out && test_line_count = 5 out && @@ -1048,7 +1048,7 @@ test_expect_success '5b: Rename/delete in order to get add/add/add conflict' ' # though, because it doesn't have anything in the way. test_setup_5c () { - test_create_repo 5c && + git init 5c && ( cd 5c && @@ -1094,8 +1094,8 @@ test_expect_success '5c: Transitive rename would cause rename/rename/rename/add/ git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/rename).*x/d.*w/d.*z/d" out && - test_i18ngrep "CONFLICT (add/add).* y/d" out && + test_grep "CONFLICT (rename/rename).*x/d.*w/d.*z/d" out && + test_grep "CONFLICT (add/add).* y/d" out && git ls-files -s >out && test_line_count = 9 out && @@ -1138,7 +1138,7 @@ test_expect_success '5c: Transitive rename would cause rename/rename/rename/add/ # directory rename detection for z/f -> y/f. test_setup_5d () { - test_create_repo 5d && + git init 5d && ( cd 5d && @@ -1179,7 +1179,7 @@ test_expect_success '5d: Directory/file/file conflict due to directory rename' ' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (file/directory).*y/d" out && + test_grep "CONFLICT (file/directory).*y/d" out && git ls-files -s >out && test_line_count = 6 out && @@ -1239,7 +1239,7 @@ test_expect_success '5d: Directory/file/file conflict due to directory rename' ' # it is also involved in a rename/delete conflict. test_setup_6a () { - test_create_repo 6a && + git init 6a && ( cd 6a && @@ -1278,7 +1278,7 @@ test_expect_success '6a: Tricky rename/delete' ' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/delete).*z/c.*y/c" out && + test_grep "CONFLICT (rename/delete).*z/c.*y/c" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then @@ -1337,7 +1337,7 @@ test_expect_success '6a: Tricky rename/delete' ' # the behavior on testcases 6b2 and 8e, and introduced this 6b1 testcase. test_setup_6b1 () { - test_create_repo 6b1 && + git init 6b1 && ( cd 6b1 && @@ -1415,7 +1415,7 @@ test_expect_merge_algorithm failure success '6b1: Same renames done on both side # the z/ -> y/ rename. test_setup_6b2 () { - test_create_repo 6b2 && + git init 6b2 && ( cd 6b2 && @@ -1479,7 +1479,7 @@ test_expect_merge_algorithm failure success '6b2: Same rename done on both sides # "accidentally detect a rename" and give us y/{b,c,d}. test_setup_6c () { - test_create_repo 6c && + git init 6c && ( cd 6c && @@ -1542,7 +1542,7 @@ test_expect_success '6c: Rename only done on same side' ' # doesn't "accidentally detect a rename" and give us y/{b,c,d}. test_setup_6d () { - test_create_repo 6d && + git init 6d && ( cd 6d && @@ -1605,7 +1605,7 @@ test_expect_success '6d: We do not always want transitive renaming' ' # add/add conflict on y/d_1 vs y/d_2. test_setup_6e () { - test_create_repo 6e && + git init 6e && ( cd 6e && @@ -1700,7 +1700,7 @@ test_expect_success '6e: Add/add from one side' ' # NOTE: There's a rename of z/ here, y/ has more renames, so z/d -> y/d. test_setup_7a () { - test_create_repo 7a && + git init 7a && ( cd 7a && @@ -1740,8 +1740,8 @@ test_expect_success '7a: rename-dir vs. rename-dir (NOT split evenly) PLUS add-o git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/rename).*z/b.*y/b.*w/b" out && - test_i18ngrep "CONFLICT (rename/rename).*z/c.*y/c.*x/c" out && + test_grep "CONFLICT (rename/rename).*z/b.*y/b.*w/b" out && + test_grep "CONFLICT (rename/rename).*z/c.*y/c.*x/c" out && git ls-files -s >out && test_line_count = 7 out && @@ -1772,7 +1772,7 @@ test_expect_success '7a: rename-dir vs. rename-dir (NOT split evenly) PLUS add-o # Expected: y/{b,c}, CONFLICT(rename/rename(2to1): x/d_1, w/d_2 -> y_d) test_setup_7b () { - test_create_repo 7b && + git init 7b && ( cd 7b && @@ -1813,7 +1813,7 @@ test_expect_success '7b: rename/rename(2to1), but only due to transitive rename' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (\(.*\)/\1)" out && + test_grep "CONFLICT (\(.*\)/\1)" out && git ls-files -s >out && test_line_count = 4 out && @@ -1861,7 +1861,7 @@ test_expect_success '7b: rename/rename(2to1), but only due to transitive rename' # nor CONFLiCT x/d -> w/d vs. y/d vs. z/d) test_setup_7c () { - test_create_repo 7c && + git init 7c && ( cd 7c && @@ -1900,7 +1900,7 @@ test_expect_success '7c: rename/rename(1to...2or3); transitive rename may add co git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/rename).*x/d.*w/d.*y/d" out && + test_grep "CONFLICT (rename/rename).*x/d.*w/d.*y/d" out && git ls-files -s >out && test_line_count = 5 out && @@ -1926,7 +1926,7 @@ test_expect_success '7c: rename/rename(1to...2or3); transitive rename may add co # NOTE: z->y so NOT CONFLICT(delete x/d vs rename to z/d) test_setup_7d () { - test_create_repo 7d && + git init 7d && ( cd 7d && @@ -1965,7 +1965,7 @@ test_expect_success '7d: transitive rename involved in rename/delete; how is it git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out && + test_grep "CONFLICT (rename/delete).*x/d.*y/d" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then @@ -2027,7 +2027,7 @@ test_expect_success '7d: transitive rename involved in rename/delete; how is it # how it's resolved. test_setup_7e () { - test_create_repo 7e && + git init 7e && ( cd 7e && @@ -2071,7 +2071,7 @@ test_expect_success '7e: transitive rename in rename/delete AND dirs in the way' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out && + test_grep "CONFLICT (rename/delete).*x/d.*y/d" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then @@ -2137,7 +2137,7 @@ test_expect_success '7e: transitive rename in rename/delete AND dirs in the way' # we potentially could. test_setup_8a () { - test_create_repo 8a && + git init 8a && ( cd 8a && @@ -2216,7 +2216,7 @@ test_expect_success '8a: Dual-directory rename, one into the others way' ' # e_1 and e_2. test_setup_8b () { - test_create_repo 8b && + git init 8b && ( cd 8b && @@ -2290,7 +2290,7 @@ test_expect_success '8b: Dual-directory rename, one into the others way, with co # notes in 8d. test_setup_8c () { - test_create_repo 8c && + git init 8c && ( cd 8c && @@ -2330,7 +2330,7 @@ test_expect_success '8c: modify/delete or rename+modify/delete' ' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "CONFLICT (modify/delete).* z/d" out && + test_grep "CONFLICT (modify/delete).* z/d" out && git ls-files -s >out && test_line_count = 5 out && @@ -2370,7 +2370,7 @@ test_expect_success '8c: modify/delete or rename+modify/delete' ' # differently. test_setup_8d () { - test_create_repo 8d && + git init 8d && ( cd 8d && @@ -2453,7 +2453,7 @@ test_expect_success '8d: rename/delete...or not?' ' # the behavior, and predict it without computing as many details. test_setup_8e () { - test_create_repo 8e && + git init 8e && ( cd 8e && @@ -2491,8 +2491,8 @@ test_expect_success '8e: Both sides rename, one side adds to original directory' git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT.*rename/rename.*z/c.*y/c.*w/c out && - test_i18ngrep CONFLICT.*rename/rename.*z/b.*y/b.*w/b out && + test_grep CONFLICT.*rename/rename.*z/c.*y/c.*w/c out && + test_grep CONFLICT.*rename/rename.*z/b.*y/b.*w/b out && git ls-files -s >out && test_line_count = 7 out && @@ -2537,7 +2537,7 @@ test_expect_success '8e: Both sides rename, one side adds to original directory' # of that could take the new file in commit B at z/i to x/w/i or x/i. test_setup_9a () { - test_create_repo 9a && + git init 9a && ( cd 9a && @@ -2609,7 +2609,7 @@ test_expect_success '9a: Inner renamed directory within outer renamed directory' # Expected: y/{b,c,d_merged} test_setup_9b () { - test_create_repo 9b && + git init 9b && ( cd 9b && @@ -2697,7 +2697,7 @@ test_expect_success '9b: Transitive rename with content merge' ' # history for any implicit directory renames. test_setup_9c () { - test_create_repo 9c && + git init 9c && ( cd 9c && @@ -2741,7 +2741,7 @@ test_expect_success '9c: Doubly transitive rename?' ' git checkout A^0 && git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "WARNING: Avoiding applying x -> z rename to x/f" out && + test_grep "WARNING: Avoiding applying x -> z rename to x/f" out && git ls-files -s >out && test_line_count = 6 out && @@ -2786,7 +2786,7 @@ test_expect_success '9c: Doubly transitive rename?' ' # testcases and simplifies things for the user. test_setup_9d () { - test_create_repo 9d && + git init 9d && ( cd 9d && @@ -2830,10 +2830,10 @@ test_expect_success '9d: N-way transitive rename?' ' git checkout A^0 && git -c merge.directoryRenames=true merge -s recursive B^0 >out && - test_i18ngrep "WARNING: Avoiding applying z -> y rename to z/t" out && - test_i18ngrep "WARNING: Avoiding applying y -> x rename to y/a" out && - test_i18ngrep "WARNING: Avoiding applying x -> w rename to x/b" out && - test_i18ngrep "WARNING: Avoiding applying w -> v rename to w/c" out && + test_grep "WARNING: Avoiding applying z -> y rename to z/t" out && + test_grep "WARNING: Avoiding applying y -> x rename to y/a" out && + test_grep "WARNING: Avoiding applying x -> w rename to x/b" out && + test_grep "WARNING: Avoiding applying w -> v rename to w/c" out && git ls-files -s >out && test_line_count = 7 out && @@ -2861,7 +2861,7 @@ test_expect_success '9d: N-way transitive rename?' ' # dir1/yo, dir2/yo, dir3/yo, dirN/yo test_setup_9e () { - test_create_repo 9e && + git init 9e && ( cd 9e && @@ -2954,7 +2954,7 @@ test_expect_success '9e: N-to-1 whammo' ' # Expected: priority/{a,b}/$more_files, priority/c test_setup_9f () { - test_create_repo 9f && + git init 9f && ( cd 9f && @@ -3027,7 +3027,7 @@ test_expect_success '9f: Renamed directory that only contained immediate subdirs # viewpoint... test_setup_9g () { - test_create_repo 9g && + git init 9g && ( cd 9g && @@ -3096,7 +3096,7 @@ test_expect_failure '9g: Renamed directory that only contained immediate subdirs # NOTE: If we applied the z/ -> y/ rename to z/d, then we'd end up with # a rename/rename(1to2) conflict (z/d -> y/d vs. x/d) test_setup_9h () { - test_create_repo 9h && + git init 9h && ( cd 9h && @@ -3177,7 +3177,7 @@ test_expect_success '9h: Avoid dir rename on merely modified path' ' # ERROR_MSG(untracked working tree files would be overwritten by merge) test_setup_10a () { - test_create_repo 10a && + git init 10a && ( cd 10a && @@ -3215,7 +3215,7 @@ test_expect_success '10a: Overwrite untracked with normal rename/delete' ' test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "The following untracked working tree files would be overwritten by merge" err && + test_grep "The following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 1 out && @@ -3243,7 +3243,7 @@ test_expect_success '10a: Overwrite untracked with normal rename/delete' ' # ERROR_MSG(refusing to lose untracked file at 'y/d') test_setup_10b () { - test_create_repo 10b && + git init 10b && ( cd 10b && @@ -3287,7 +3287,7 @@ test_expect_success '10b: Overwrite untracked with dir rename + delete' ' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err && + test_grep "error: The following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 1 out && @@ -3296,8 +3296,8 @@ test_expect_success '10b: Overwrite untracked with dir rename + delete' ' git ls-files -o >out && test_line_count = 5 out else - test_i18ngrep "CONFLICT (rename/delete).*Version B\^0 of y/d left in tree at y/d~B\^0" out && - test_i18ngrep "Error: Refusing to lose untracked file at y/e; writing to y/e~B\^0 instead" out && + test_grep "CONFLICT (rename/delete).*Version B\^0 of y/d left in tree at y/d~B\^0" out && + test_grep "Error: Refusing to lose untracked file at y/e; writing to y/e~B\^0 instead" out && git ls-files -s >out && test_line_count = 3 out && @@ -3334,7 +3334,7 @@ test_expect_success '10b: Overwrite untracked with dir rename + delete' ' # ERROR_MSG(Refusing to lose untracked file at y/c) test_setup_10c () { - test_create_repo 10c_$1 && + git init 10c_$1 && ( cd 10c_$1 && @@ -3377,7 +3377,7 @@ test_expect_success '10c1: Overwrite untracked with dir rename/rename(1to2)' ' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err && + test_grep "error: The following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 4 out && @@ -3386,8 +3386,8 @@ test_expect_success '10c1: Overwrite untracked with dir rename/rename(1to2)' ' git ls-files -o >out && test_line_count = 3 out else - test_i18ngrep "CONFLICT (rename/rename)" out && - test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~B\^0 instead" out && + test_grep "CONFLICT (rename/rename)" out && + test_grep "Refusing to lose untracked file at y/c; adding as y/c~B\^0 instead" out && git ls-files -s >out && test_line_count = 6 out && @@ -3428,7 +3428,7 @@ test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), oth if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err && + test_grep "error: The following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 4 out && @@ -3437,8 +3437,8 @@ test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), oth git ls-files -o >out && test_line_count = 3 out else - test_i18ngrep "CONFLICT (rename/rename)" out && - test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out && + test_grep "CONFLICT (rename/rename)" out && + test_grep "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 && @@ -3472,7 +3472,7 @@ test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), oth # ERROR_MSG(Refusing to lose untracked file at y/wham) test_setup_10d () { - test_create_repo 10d && + git init 10d && ( cd 10d && @@ -3517,7 +3517,7 @@ test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' ' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err && + test_grep "error: The following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 6 out && @@ -3526,8 +3526,8 @@ test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' ' git ls-files -o >out && test_line_count = 3 out else - test_i18ngrep "CONFLICT (rename/rename)" out && - test_i18ngrep "Refusing to lose untracked file at y/wham" out && + test_grep "CONFLICT (rename/rename)" out && + test_grep "Refusing to lose untracked file at y/wham" out && git ls-files -s >out && test_line_count = 6 out && @@ -3568,7 +3568,7 @@ test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' ' # Expected: y/{a,b,c} + untracked z/c test_setup_10e () { - test_create_repo 10e && + git init 10e && ( cd 10e && @@ -3606,7 +3606,7 @@ test_expect_merge_algorithm failure success '10e: Does git complain about untrac echo random >z/c && git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep ! "following untracked working tree files would be overwritten by merge" err && + test_grep ! "following untracked working tree files would be overwritten by merge" err && git ls-files -s >out && test_line_count = 3 out && @@ -3650,7 +3650,7 @@ test_expect_merge_algorithm failure success '10e: Does git complain about untrac # z/c with uncommitted mods on top of A:z/c_v1 test_setup_11a () { - test_create_repo 11a && + git init 11a && ( cd 11a && @@ -3690,9 +3690,9 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' ' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else - test_i18ngrep "Refusing to lose dirty file at z/c" out && + test_grep "Refusing to lose dirty file at z/c" out && git ls-files -s >out && test_line_count = 2 out && @@ -3728,7 +3728,7 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' ' test_setup_11b () { - test_create_repo 11b && + git init 11b && ( cd 11b && @@ -3770,10 +3770,10 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename' then test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep "Refusing to lose dirty file at z/c" out && + test_grep "Refusing to lose dirty file at z/c" out && git ls-files -s >out && test_line_count = 3 out && @@ -3810,7 +3810,7 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename' # y/c left untouched (still has uncommitted mods) test_setup_11c () { - test_create_repo 11c && + git init 11c && ( cd 11c && @@ -3853,9 +3853,9 @@ test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else - test_i18ngrep "following files would be overwritten by merge" err + test_grep "following files would be overwritten by merge" err fi && grep -q stuff y/c && @@ -3883,7 +3883,7 @@ test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict' # y/{a,c~HEAD,c/d}, x/b, now-untracked z/c_v1 with uncommitted mods test_setup_11d () { - test_create_repo 11d && + git init 11d && ( cd 11d && @@ -3927,9 +3927,9 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict' if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else - test_i18ngrep "Refusing to lose dirty file at z/c" out && + test_grep "Refusing to lose dirty file at z/c" out && git ls-files -s >out && test_line_count = 4 out && @@ -3968,7 +3968,7 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict' # y/c has dirty file from before merge test_setup_11e () { - test_create_repo 11e && + git init 11e && ( cd 11e && @@ -4013,10 +4013,10 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else - test_i18ngrep "CONFLICT (rename/rename)" out && - test_i18ngrep "Refusing to lose dirty file at y/c" out && + test_grep "CONFLICT (rename/rename)" out && + test_grep "Refusing to lose dirty file at y/c" out && git ls-files -s >out && test_line_count = 7 out && @@ -4060,7 +4060,7 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to # ERROR_MSG(Refusing to lose dirty file at y/wham) test_setup_11f () { - test_create_repo 11f && + git init 11f && ( cd 11f && @@ -4102,10 +4102,10 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to if test "$GIT_TEST_MERGE_ALGORITHM" = ort then test_path_is_missing .git/MERGE_HEAD && - test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err + test_grep "error: Your local changes to the following files would be overwritten by merge" err else - test_i18ngrep "CONFLICT (rename/rename)" out && - test_i18ngrep "Refusing to lose dirty file at y/wham" out && + test_grep "CONFLICT (rename/rename)" out && + test_grep "Refusing to lose dirty file at y/wham" out && git ls-files -s >out && test_line_count = 4 out && @@ -4155,7 +4155,7 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to # Expected: node1/{leaf1,leaf2,leaf5,node2/{leaf3,leaf4,leaf6}} test_setup_12a () { - test_create_repo 12a && + git init 12a && ( cd 12a && @@ -4238,7 +4238,7 @@ test_expect_success '12a: Moving one directory hierarchy into another' ' # node2/node1/{leaf1, leaf2} test_setup_12b1 () { - test_create_repo 12b1 && + git init 12b1 && ( cd 12b1 && @@ -4327,7 +4327,7 @@ test_expect_merge_algorithm failure success '12b1: Moving two directory hierarch # even simple rules give weird results when given weird inputs. test_setup_12b2 () { - test_create_repo 12b2 && + git init 12b2 && ( cd 12b2 && @@ -4402,7 +4402,7 @@ test_expect_success '12b2: Moving two directory hierarchies into each other' ' # each side of the merge. test_setup_12c1 () { - test_create_repo 12c1 && + git init 12c1 && ( cd 12c1 && @@ -4421,14 +4421,14 @@ test_setup_12c1 () { git checkout A && git mv node2/ node1/ && - for i in `git ls-files`; do echo side A >>$i; done && + for i in $(git ls-files); do echo side A >>$i; done && git add -u && test_tick && git commit -m "A" && git checkout B && git mv node1/ node2/ && - for i in `git ls-files`; do echo side B >>$i; done && + for i in $(git ls-files); do echo side B >>$i; done && git add -u && test_tick && git commit -m "B" @@ -4492,7 +4492,7 @@ test_expect_merge_algorithm failure success '12c1: Moving one directory hierarch # on each side of the merge. test_setup_12c2 () { - test_create_repo 12c2 && + git init 12c2 && ( cd 12c2 && @@ -4511,7 +4511,7 @@ test_setup_12c2 () { git checkout A && git mv node2/ node1/ && - for i in `git ls-files`; do echo side A >>$i; done && + for i in $(git ls-files); do echo side A >>$i; done && git add -u && echo leaf5 >node1/leaf5 && git add node1/leaf5 && @@ -4520,7 +4520,7 @@ test_setup_12c2 () { git checkout B && git mv node1/ node2/ && - for i in `git ls-files`; do echo side B >>$i; done && + for i in $(git ls-files); do echo side B >>$i; done && git add -u && echo leaf6 >node2/leaf6 && git add node2/leaf6 && @@ -4584,7 +4584,7 @@ test_expect_success '12c2: Moving one directory hierarchy into another w/ conten # Expected: subdir/foo, bar test_setup_12d () { - test_create_repo 12d && + git init 12d && ( cd 12d && @@ -4642,7 +4642,7 @@ test_expect_success '12d: Rename/merge subdir into the root, variant 1' ' # Expected: foo, bar test_setup_12e () { - test_create_repo 12e && + git init 12e && ( cd 12e && @@ -4743,7 +4743,7 @@ test_expect_success '12e: Rename/merge subdir into the root, variant 2' ' # pick and re-applying them in the subsequent one. test_setup_12f () { - test_create_repo 12f && + git init 12f && ( cd 12f && @@ -4759,7 +4759,7 @@ test_setup_12f () { echo g >dir/subdir/tweaked/g && echo h >dir/subdir/tweaked/h && test_seq 20 30 >dir/subdir/tweaked/Makefile && - for i in `test_seq 1 88`; do + for i in $(test_seq 1 88); do echo content $i >dir/unchanged/file_$i done && git add . && @@ -4902,7 +4902,7 @@ test_expect_merge_algorithm failure success '12f: Trivial directory resolve, cac # Expected: newfile_{merged}, newdir/{a_B,b_B,c_A} test_setup_12g () { - test_create_repo 12g && + git init 12g && ( cd 12g && @@ -4973,7 +4973,7 @@ test_expect_success '12g: Testcase with two kinds of "relevant" renames' ' # Expected: newdir/{alpha_2, b} test_setup_12h () { - test_create_repo 12h && + git init 12h && ( cd 12h && @@ -5032,7 +5032,7 @@ test_expect_failure '12h: renaming a file within a renamed directory' ' # source/bar vs. source/subdir/bar test_setup_12i () { - test_create_repo 12i && + git init 12i && ( cd 12i && @@ -5090,7 +5090,7 @@ test_expect_success '12i: Directory rename causes rename-to-self' ' # Expected: {foo, bar, baz_2}, with conflicts on bar vs. subdir/bar test_setup_12j () { - test_create_repo 12j && + git init 12j && ( cd 12j && @@ -5148,7 +5148,7 @@ test_expect_success '12j: Directory rename to root causes rename-to-self' ' # Expected: dirA/{foo, bar, baz_2}, with conflicts on dirA/bar vs. dirB/bar test_setup_12k () { - test_create_repo 12k && + git init 12k && ( cd 12k && @@ -5199,6 +5199,167 @@ test_expect_success '12k: Directory rename with sibling causes rename-to-self' ' ) ' +# Testcase 12l, Both sides rename a directory into the other side, both add +# a file which after directory renames are the same filename +# Commit O: sub1/file, sub2/other +# Commit A: sub3/file, sub2/{other, new_add_add_file_1} +# Commit B: sub1/{file, newfile}, sub1/sub2/{other, new_add_add_file_2} +# +# In words: +# A: sub1/ -> sub3/, add sub2/new_add_add_file_1 +# B: sub2/ -> sub1/sub2, add sub1/newfile, add sub1/sub2/new_add_add_file_2 +# +# Expected: sub3/{file, newfile, sub2/other} +# CONFLICT (add/add): sub1/sub2/new_add_add_file +# +# Note that sub1/newfile is not extraneous. Directory renames are only +# detected if they are needed, and they are only needed if the old directory +# had a new file added on the opposite side of history. So sub1/newfile +# is needed for there to be a sub1/ -> sub3/ rename. + +test_setup_12l () { + git init 12l_$1 && + ( + cd 12l_$1 && + + mkdir sub1 sub2 + echo file >sub1/file && + echo other >sub2/other && + git add sub1 sub2 && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + git mv sub1 sub3 && + echo conflicting >sub2/new_add_add_file && + git add sub2 && + test_tick && + git add -u && + git commit -m "A" && + + git checkout B && + echo dissimilar >sub2/new_add_add_file && + echo brand >sub1/newfile && + git add sub1 sub2 && + git mv sub2 sub1 && + test_tick && + git commit -m "B" + ) +} + +test_expect_merge_algorithm failure success '12l (B into A): Rename into each other + add/add conflict' ' + test_setup_12l BintoA && + ( + cd 12l_BintoA && + + git checkout -q A^0 && + + test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 && + + test_stdout_line_count = 5 git ls-files -s && + + git rev-parse >actual \ + :0:sub3/file :0:sub3/newfile :0:sub3/sub2/other \ + :2:sub1/sub2/new_add_add_file \ + :3:sub1/sub2/new_add_add_file && + git rev-parse >expect \ + O:sub1/file B:sub1/newfile O:sub2/other \ + A:sub2/new_add_add_file \ + B:sub1/sub2/new_add_add_file && + test_cmp expect actual && + + git ls-files -o >actual && + test_write_lines actual expect >expect && + test_cmp expect actual + ) +' + +test_expect_merge_algorithm failure success '12l (A into B): Rename into each other + add/add conflict' ' + test_setup_12l AintoB && + ( + cd 12l_AintoB && + + git checkout -q B^0 && + + test_must_fail git -c merge.directoryRenames=true merge -s recursive A^0 && + + test_stdout_line_count = 5 git ls-files -s && + + git rev-parse >actual \ + :0:sub3/file :0:sub3/newfile :0:sub3/sub2/other \ + :2:sub1/sub2/new_add_add_file \ + :3:sub1/sub2/new_add_add_file && + git rev-parse >expect \ + O:sub1/file B:sub1/newfile O:sub2/other \ + B:sub1/sub2/new_add_add_file \ + A:sub2/new_add_add_file && + test_cmp expect actual && + + git ls-files -o >actual && + test_write_lines actual expect >expect && + test_cmp expect actual + ) +' + +# Testcase 12m, Directory rename, plus change of parent dir to symlink +# Commit O: dir/subdir/file +# Commit A: renamed-dir/subdir/file +# Commit B: dir/subdir +# In words: +# A: dir/subdir/ -> renamed-dir/subdir +# B: delete dir/subdir/file, add dir/subdir as symlink +# +# Expected: CONFLICT (rename/delete): renamed-dir/subdir/file, +# CONFLICT (file location): renamed-dir/subdir vs. dir/subdir +# CONFLICT (directory/file): renamed-dir/subdir symlink has +# renamed-dir/subdir in the way + +test_setup_12m () { + git init 12m && + ( + cd 12m && + + mkdir -p dir/subdir && + echo 1 >dir/subdir/file && + git add . && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git switch A && + git mv dir/ renamed-dir/ && + git add . && + git commit -m "A" && + + git switch B && + git rm dir/subdir/file && + mkdir dir && + ln -s /dev/null dir/subdir && + git add . && + git commit -m "B" + ) +} + +test_expect_merge_algorithm failure success '12m: Change parent of renamed-dir to symlink on other side' ' + test_setup_12m && + ( + cd 12m && + + git checkout -q A^0 && + + test_must_fail git -c merge.directoryRenames=conflict merge -s recursive B^0 && + + test_stdout_line_count = 3 git ls-files -s && + test_stdout_line_count = 2 ls -1 renamed-dir && + test_path_is_missing dir + ) +' + ########################################################################### # SECTION 13: Checking informational and conflict messages # @@ -5217,7 +5378,7 @@ test_expect_success '12k: Directory rename with sibling causes rename-to-self' ' # Expected: y/{b,c,d,e/f}, with notices/conflicts for both y/d and y/e/f test_setup_13a () { - test_create_repo 13a_$1 && + git init 13a_$1 && ( cd 13a_$1 && @@ -5256,8 +5417,8 @@ test_expect_success '13a(conflict): messages for newly added files' ' test_must_fail git merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT..file.location.*z/e/f.added.in.B^0.*y/e/f out && - test_i18ngrep CONFLICT..file.location.*z/d.added.in.B^0.*y/d out && + test_grep CONFLICT..file.location.*z/e/f.added.in.B^0.*y/e/f out && + test_grep CONFLICT..file.location.*z/d.added.in.B^0.*y/d out && git ls-files >paths && ! grep z/ paths && @@ -5280,8 +5441,8 @@ test_expect_success '13a(info): messages for newly added files' ' git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep Path.updated:.*z/e/f.added.in.B^0.*y/e/f out && - test_i18ngrep Path.updated:.*z/d.added.in.B^0.*y/d out && + test_grep Path.updated:.*z/e/f.added.in.B^0.*y/e/f out && + test_grep Path.updated:.*z/d.added.in.B^0.*y/d out && git ls-files >paths && ! grep z/ paths && @@ -5304,7 +5465,7 @@ test_expect_success '13a(info): messages for newly added files' ' # one about content, and one about file location test_setup_13b () { - test_create_repo 13b_$1 && + git init 13b_$1 && ( cd 13b_$1 && @@ -5346,8 +5507,8 @@ test_expect_success '13b(conflict): messages for transitive rename with conflict test_must_fail git merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT.*content.*Merge.conflict.in.y/d out && - test_i18ngrep CONFLICT..file.location.*x/d.renamed.to.z/d.*moved.to.y/d out && + test_grep CONFLICT.*content.*Merge.conflict.in.y/d out && + test_grep CONFLICT..file.location.*x/d.renamed.to.z/d.*moved.to.y/d out && git ls-files >paths && ! grep z/ paths && @@ -5368,8 +5529,8 @@ test_expect_success '13b(info): messages for transitive rename with conflicted c test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT.*content.*Merge.conflict.in.y/d out && - test_i18ngrep Path.updated:.*x/d.renamed.to.z/d.in.B^0.*moving.it.to.y/d out && + test_grep CONFLICT.*content.*Merge.conflict.in.y/d out && + test_grep Path.updated:.*x/d.renamed.to.z/d.in.B^0.*moving.it.to.y/d out && git ls-files >paths && ! grep z/ paths && @@ -5391,7 +5552,7 @@ test_expect_success '13b(info): messages for transitive rename with conflicted c # shown in testcase 13d. test_setup_13c () { - test_create_repo 13c_$1 && + git init 13c_$1 && ( cd 13c_$1 && @@ -5432,7 +5593,7 @@ test_expect_success '13c(conflict): messages for rename/rename(1to1) via transit test_must_fail git merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT..file.location.*x/d.renamed.to.z/d.*moved.to.y/d out && + test_grep CONFLICT..file.location.*x/d.renamed.to.z/d.*moved.to.y/d out && git ls-files >paths && ! grep z/ paths && @@ -5453,7 +5614,7 @@ test_expect_success '13c(info): messages for rename/rename(1to1) via transitive git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep Path.updated:.*x/d.renamed.to.z/d.in.B^0.*moving.it.to.y/d out && + test_grep Path.updated:.*x/d.renamed.to.z/d.in.B^0.*moving.it.to.y/d out && git ls-files >paths && ! grep z/ paths && @@ -5479,7 +5640,7 @@ test_expect_success '13c(info): messages for rename/rename(1to1) via transitive # No conflict in where a/y ends up, so put it in d/y. test_setup_13d () { - test_create_repo 13d_$1 && + git init 13d_$1 && ( cd 13d_$1 && @@ -5521,8 +5682,8 @@ test_expect_success '13d(conflict): messages for rename/rename(1to1) via dual tr test_must_fail git merge -s recursive B^0 >out 2>err && - test_i18ngrep CONFLICT..file.location.*a/y.renamed.to.b/y.*moved.to.d/y out && - test_i18ngrep CONFLICT..file.location.*a/y.renamed.to.c/y.*moved.to.d/y out && + test_grep CONFLICT..file.location.*a/y.renamed.to.b/y.*moved.to.d/y out && + test_grep CONFLICT..file.location.*a/y.renamed.to.c/y.*moved.to.d/y out && git ls-files >paths && ! grep b/ paths && @@ -5545,8 +5706,8 @@ test_expect_success '13d(info): messages for rename/rename(1to1) via dual transi git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep Path.updated.*a/y.renamed.to.b/y.*moving.it.to.d/y out && - test_i18ngrep Path.updated.*a/y.renamed.to.c/y.*moving.it.to.d/y out && + test_grep Path.updated.*a/y.renamed.to.b/y.*moving.it.to.d/y out && + test_grep Path.updated.*a/y.renamed.to.c/y.*moving.it.to.d/y out && git ls-files >paths && ! grep b/ paths && @@ -5605,7 +5766,7 @@ test_expect_success '13d(info): messages for rename/rename(1to1) via dual transi # least avoids hitting a BUG(). # test_setup_13e () { - test_create_repo 13e && + git init 13e && ( cd 13e && @@ -5660,9 +5821,9 @@ test_expect_success '13e: directory rename detection in recursive case' ' git -c merge.directoryRenames=conflict merge -s recursive C^0 >out 2>err && - test_i18ngrep ! CONFLICT out && - test_i18ngrep ! BUG: err && - test_i18ngrep ! core.dumped err && + test_grep ! CONFLICT out && + test_grep ! BUG: err && + test_grep ! core.dumped err && test_must_be_empty err && git ls-files >paths && |