diff options
Diffstat (limited to 't/t6416-recursive-corner-cases.sh')
-rwxr-xr-x | t/t6416-recursive-corner-cases.sh | 231 |
1 files changed, 157 insertions, 74 deletions
diff --git a/t/t6416-recursive-corner-cases.sh b/t/t6416-recursive-corner-cases.sh index fd98989b14..84f5082366 100755 --- a/t/t6416-recursive-corner-cases.sh +++ b/t/t6416-recursive-corner-cases.sh @@ -2,7 +2,11 @@ test_description='recursive merge corner cases involving criss-cross merges' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-merge.sh # # L1 L2 @@ -384,7 +388,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete' ' test_line_count = 2 out && git rev-parse >expect \ - master:file B:file && + main:file B:file && git rev-parse >actual \ :1:file :2:file && test_cmp expect actual @@ -406,7 +410,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev test_line_count = 2 out && git rev-parse >expect \ - master:file B:file && + main:file B:file && git rev-parse >actual \ :1:file :3:file && test_cmp expect actual @@ -537,9 +541,15 @@ test_expect_success 'setup differently handled merges of directory/file conflict git checkout B^0 && test_must_fail git merge C^0 && - git clean -fd && - git rm -rf a/ && - git rm a && + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git rm -rf a/ && + git rm a~HEAD + else + git clean -fd && + git rm -rf a/ && + git rm a + fi && git cat-file -p B:a >a2 && git add a2 && git commit -m D2 && @@ -558,7 +568,12 @@ test_expect_success 'setup differently handled merges of directory/file conflict git checkout C^0 && test_must_fail git merge B^0 && - git clean -fd && + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git rm a~B^0 + else + git clean -fd + fi && git rm -rf a/ && test_write_lines 1 2 3 4 5 6 7 8 >a && git add a && @@ -567,9 +582,15 @@ test_expect_success 'setup differently handled merges of directory/file conflict git checkout C^0 && test_must_fail git merge B^0 && - git clean -fd && - git rm -rf a/ && - git rm a && + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git rm -rf a/ && + git rm a~B^0 + else + git clean -fd && + git rm -rf a/ && + git rm a + fi && test_write_lines 1 2 3 4 5 6 7 8 >a2 && git add a2 && git commit -m E4 && @@ -587,18 +608,34 @@ test_expect_success 'merge of D1 & E1 fails but has appropriate contents' ' test_must_fail git merge -s recursive E1^0 && - git ls-files -s >out && - test_line_count = 2 out && - git ls-files -u >out && - test_line_count = 1 out && - git ls-files -o >out && - test_line_count = 1 out && - - git rev-parse >expect \ - A:ignore-me B:a && - git rev-parse >actual \ - :0:ignore-me :2:a && - test_cmp expect actual + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git ls-files -s >out && + test_line_count = 3 out && + git ls-files -u >out && + test_line_count = 2 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + A:ignore-me B:a D1:a && + git rev-parse >actual \ + :0:ignore-me :1:a :2:a && + test_cmp expect actual + else + git ls-files -s >out && + test_line_count = 2 out && + git ls-files -u >out && + test_line_count = 1 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + A:ignore-me B:a && + git rev-parse >actual \ + :0:ignore-me :2:a && + test_cmp expect actual + fi ) ' @@ -612,18 +649,34 @@ test_expect_success 'merge of E1 & D1 fails but has appropriate contents' ' test_must_fail git merge -s recursive D1^0 && - git ls-files -s >out && - test_line_count = 2 out && - git ls-files -u >out && - test_line_count = 1 out && - git ls-files -o >out && - test_line_count = 1 out && - - git rev-parse >expect \ - A:ignore-me B:a && - git rev-parse >actual \ - :0:ignore-me :3:a && - test_cmp expect actual + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git ls-files -s >out && + test_line_count = 3 out && + git ls-files -u >out && + test_line_count = 2 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + A:ignore-me B:a D1:a && + git rev-parse >actual \ + :0:ignore-me :1:a :3:a && + test_cmp expect actual + else + git ls-files -s >out && + test_line_count = 2 out && + git ls-files -u >out && + test_line_count = 1 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + A:ignore-me B:a && + git rev-parse >actual \ + :0:ignore-me :3:a && + test_cmp expect actual + fi ) ' @@ -637,17 +690,32 @@ test_expect_success 'merge of D1 & E2 fails but has appropriate contents' ' test_must_fail git merge -s recursive E2^0 && - git ls-files -s >out && - test_line_count = 4 out && - git ls-files -u >out && - test_line_count = 3 out && - git ls-files -o >out && - test_line_count = 2 out && - - git rev-parse >expect \ - B:a E2:a/file C:a/file A:ignore-me && - git rev-parse >actual \ - :2:a :3:a/file :1:a/file :0:ignore-me && + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git ls-files -s >out && + test_line_count = 5 out && + git ls-files -u >out && + test_line_count = 4 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + B:a D1:a E2:a/file C:a/file A:ignore-me && + git rev-parse >actual \ + :1:a~HEAD :2:a~HEAD :3:a/file :1:a/file :0:ignore-me + else + git ls-files -s >out && + test_line_count = 4 out && + git ls-files -u >out && + test_line_count = 3 out && + git ls-files -o >out && + test_line_count = 2 out && + + git rev-parse >expect \ + B:a E2:a/file C:a/file A:ignore-me && + git rev-parse >actual \ + :2:a :3:a/file :1:a/file :0:ignore-me + fi && test_cmp expect actual && test_path_is_file a~HEAD @@ -664,17 +732,32 @@ test_expect_success 'merge of E2 & D1 fails but has appropriate contents' ' test_must_fail git merge -s recursive D1^0 && - git ls-files -s >out && - test_line_count = 4 out && - git ls-files -u >out && - test_line_count = 3 out && - git ls-files -o >out && - test_line_count = 2 out && - - git rev-parse >expect \ - B:a E2:a/file C:a/file A:ignore-me && - git rev-parse >actual \ - :3:a :2:a/file :1:a/file :0:ignore-me && + if test "$GIT_TEST_MERGE_ALGORITHM" = ort + then + git ls-files -s >out && + test_line_count = 5 out && + git ls-files -u >out && + test_line_count = 4 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >expect \ + B:a D1:a E2:a/file C:a/file A:ignore-me && + git rev-parse >actual \ + :1:a~D1^0 :3:a~D1^0 :2:a/file :1:a/file :0:ignore-me + else + git ls-files -s >out && + test_line_count = 4 out && + git ls-files -u >out && + test_line_count = 3 out && + git ls-files -o >out && + test_line_count = 2 out && + + git rev-parse >expect \ + B:a E2:a/file C:a/file A:ignore-me && + git rev-parse >actual \ + :3:a :2:a/file :1:a/file :0:ignore-me + fi && test_cmp expect actual && test_path_is_file a~D1^0 @@ -706,7 +789,7 @@ test_expect_success 'merge of D1 & E3 succeeds' ' ) ' -test_expect_success 'merge of D1 & E4 notifies user a and a2 are related' ' +test_expect_merge_algorithm failure success 'merge of D1 & E4 puts merge of a and a2 in both a and a2' ' test_when_finished "git -C directory-file reset --hard" && test_when_finished "git -C directory-file clean -fdqx" && ( @@ -724,7 +807,7 @@ test_expect_success 'merge of D1 & E4 notifies user a and a2 are related' ' test_line_count = 1 out && git rev-parse >expect \ - A:ignore-me B:a D1:a E4:a2 && + A:ignore-me B:a E4:a2 E4:a2 && git rev-parse >actual \ :0:ignore-me :1:a~Temporary\ merge\ branch\ 2 :2:a :3:a2 && test_cmp expect actual @@ -1069,7 +1152,7 @@ test_expect_success 'setup symlink modify/modify' ' ) ' -test_expect_failure 'check symlink modify/modify' ' +test_expect_merge_algorithm failure success 'check symlink modify/modify' ' ( cd symlink-modify-modify && @@ -1135,7 +1218,7 @@ test_expect_success 'setup symlink add/add' ' ) ' -test_expect_failure 'check symlink add/add' ' +test_expect_merge_algorithm failure success 'check symlink add/add' ' ( cd symlink-add-add && @@ -1223,7 +1306,7 @@ test_expect_success 'setup submodule modify/modify' ' ) ' -test_expect_failure 'check submodule modify/modify' ' +test_expect_merge_algorithm failure success 'check submodule modify/modify' ' ( cd submodule-modify-modify && @@ -1311,7 +1394,7 @@ test_expect_success 'setup submodule add/add' ' ) ' -test_expect_failure 'check submodule add/add' ' +test_expect_merge_algorithm failure success 'check submodule add/add' ' ( cd submodule-add-add && @@ -1386,7 +1469,7 @@ test_expect_success 'setup conflicting entry types (submodule vs symlink)' ' ) ' -test_expect_failure 'check conflicting entry types (submodule vs symlink)' ' +test_expect_merge_algorithm failure success 'check conflicting entry types (submodule vs symlink)' ' ( cd submodule-symlink-add-add && @@ -1473,12 +1556,12 @@ test_expect_failure 'check conflicting modes for regular file' ' # Setup: # L1---L2 # / \ / \ -# master X ? +# main X ? # \ / \ / # R1---R2 # # Where: -# master has two files, named 'b' and 'a' +# main has two files, named 'b' and 'a' # branches L1 and R1 both modify each of the two files in conflicting ways # # L2 is a merge of R1 into L1; more on it later. @@ -1583,7 +1666,7 @@ test_expect_success 'check nested conflicts' ' cd nested_conflicts && git clean -f && - MASTER=$(git rev-parse --short master) && + MAIN=$(git rev-parse --short main) && git checkout L2^0 && # Merge must fail; there is a conflict @@ -1599,24 +1682,24 @@ test_expect_success 'check nested conflicts' ' test_line_count = 1 out && # Create a and b from virtual merge base X - git cat-file -p master:a >base && + git cat-file -p main:a >base && git cat-file -p L1:a >ours && git cat-file -p R1:a >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ ours \ base \ theirs && sed -e "s/^\([<|=>]\)/\1\1/" ours >vmb_a && - git cat-file -p master:b >base && + git cat-file -p main:b >base && git cat-file -p L1:b >ours && git cat-file -p R1:b >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ ours \ base \ @@ -1668,12 +1751,12 @@ test_expect_success 'check nested conflicts' ' # Setup: # L1---L2---L3 # / \ / \ / \ -# master X1 X2 ? +# main X1 X2 ? # \ / \ / \ / # R1---R2---R3 # # Where: -# master has one file named 'content' +# main has one file named 'content' # branches L1 and R1 both modify each of the two files in conflicting ways # # L<n> (n>1) is a merge of R<n-1> into L<n-1> @@ -1754,7 +1837,7 @@ test_expect_success 'check virtual merge base with nested conflicts' ' ( cd virtual_merge_base_has_nested_conflicts && - MASTER=$(git rev-parse --short master) && + MAIN=$(git rev-parse --short main) && git checkout L3^0 && # Merge must fail; there is a conflict @@ -1777,13 +1860,13 @@ test_expect_success 'check virtual merge base with nested conflicts' ' # Imitate X1 merge base, except without long enough conflict # markers because a subsequent sed will modify them. Put # result into vmb. - git cat-file -p master:content >base && + git cat-file -p main:content >base && git cat-file -p L:content >left && git cat-file -p R:content >right && cp left merged-once && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "$MASTER" \ + -L "$MAIN" \ -L "Temporary merge branch 2" \ merged-once \ base \ |