Preparation for a new merge strategy.

* en/merge-tests:
  t6423: add more details about direct resolution of directories
  t6423: note improved ort handling with untracked files
  t6423, t6436: note improved ort handling with dirty files
  merge tests: expect slight differences in output for recursive vs. ort
  t6423: expect improved conflict markers labels in the ort backend
  t6404, t6423: expect improved rename/delete handling in ort backend
  t6416: correct expectation for rename/rename(1to2) + directory/file
  merge tests: expect improved directory/file conflict handling in ort
  t/: new helper for tests that pass with ort but fail with recursive
This commit is contained in:
Junio C Hamano 2020-11-18 13:32:52 -08:00
Родитель 2ad1f930d2 848a856b13
Коммит 66c62eaec6
13 изменённых файлов: 786 добавлений и 365 удалений

13
t/lib-merge.sh Normal file
Просмотреть файл

@ -0,0 +1,13 @@
# Helper functions used by merge tests.
test_expect_merge_algorithm () {
status_for_recursive=$1 status_for_ort=$2
shift 2
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_expect_${status_for_ort} "$@"
else
test_expect_${status_for_recursive} "$@"
fi
}

Просмотреть файл

@ -81,7 +81,12 @@ test_expect_success 'modify/delete + directory/file conflict' '
test 5 -eq $(git ls-files -s | wc -l) && test 5 -eq $(git ls-files -s | wc -l) &&
test 4 -eq $(git ls-files -u | wc -l) && test 4 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 0 -eq $(git ls-files -o | wc -l)
else
test 1 -eq $(git ls-files -o | wc -l)
fi &&
test_path_is_file letters/file && test_path_is_file letters/file &&
test_path_is_file letters.txt && test_path_is_file letters.txt &&
@ -97,7 +102,12 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '
test 5 -eq $(git ls-files -s | wc -l) && test 5 -eq $(git ls-files -s | wc -l) &&
test 4 -eq $(git ls-files -u | wc -l) && test 4 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 0 -eq $(git ls-files -o | wc -l)
else
test 1 -eq $(git ls-files -o | wc -l)
fi &&
test_path_is_file letters/file && test_path_is_file letters/file &&
test_path_is_file letters.txt && test_path_is_file letters.txt &&

Просмотреть файл

@ -320,7 +320,12 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output && test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output &&
test_i18ngrep "Auto-merging dir" output && test_i18ngrep "Auto-merging dir" output &&
test_i18ngrep "Adding as dir~HEAD instead" output && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_i18ngrep "moving it to dir~HEAD instead" output
else
test_i18ngrep "Adding as dir~HEAD instead" output
fi &&
test 3 -eq "$(git ls-files -u | wc -l)" && test 3 -eq "$(git ls-files -u | wc -l)" &&
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
@ -342,7 +347,12 @@ test_expect_success 'Same as previous, but merged other way' '
! grep "error: refusing to lose untracked file at" errors && ! grep "error: refusing to lose untracked file at" errors &&
test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output && test_i18ngrep "CONFLICT (modify/delete): dir/file-in-the-way" output &&
test_i18ngrep "Auto-merging dir" output && test_i18ngrep "Auto-merging dir" output &&
test_i18ngrep "Adding as dir~renamed-file-has-no-conflicts instead" output && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_i18ngrep "moving it to dir~renamed-file-has-no-conflicts instead" output
else
test_i18ngrep "Adding as dir~renamed-file-has-no-conflicts instead" output
fi &&
test 3 -eq "$(git ls-files -u | wc -l)" && test 3 -eq "$(git ls-files -u | wc -l)" &&
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
@ -397,7 +407,12 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t
test_must_fail git merge --strategy=recursive dir-in-way && test_must_fail git merge --strategy=recursive dir-in-way &&
test 5 -eq "$(git ls-files -u | wc -l)" && test 5 -eq "$(git ls-files -u | wc -l)" &&
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 3 -eq "$(git ls-files -u dir~HEAD | wc -l)"
else
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)"
fi &&
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet && test_must_fail git diff --quiet &&
@ -415,7 +430,12 @@ test_expect_success 'Same as previous, but merged other way' '
test_must_fail git merge --strategy=recursive renamed-file-has-conflicts && test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
test 5 -eq "$(git ls-files -u | wc -l)" && test 5 -eq "$(git ls-files -u | wc -l)" &&
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 3 -eq "$(git ls-files -u dir~renamed-file-has-conflicts | wc -l)"
else
test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)"
fi &&
test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet && test_must_fail git diff --quiet &&
@ -471,7 +491,12 @@ test_expect_success 'both rename source and destination involved in D/F conflict
git checkout -q rename-dest^0 && git checkout -q rename-dest^0 &&
test_must_fail git merge --strategy=recursive source-conflict && test_must_fail git merge --strategy=recursive source-conflict &&
test 1 -eq "$(git ls-files -u | wc -l)" && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 2 -eq "$(git ls-files -u | wc -l)"
else
test 1 -eq "$(git ls-files -u | wc -l)"
fi &&
test_must_fail git diff --quiet && test_must_fail git diff --quiet &&
@ -505,34 +530,63 @@ test_expect_success 'setup pair rename to parent of other (D/F conflicts)' '
git commit -m "Rename one/file -> two" git commit -m "Rename one/file -> two"
' '
test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' ' if test "$GIT_TEST_MERGE_ALGORITHM" = ort
git checkout -q rename-one^0 && then
mkdir one && test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
test_must_fail git merge --strategy=recursive rename-two && git checkout -q rename-one^0 &&
mkdir one &&
test_must_fail git merge --strategy=recursive rename-two &&
test 2 -eq "$(git ls-files -u | wc -l)" && test 4 -eq "$(git ls-files -u | wc -l)" &&
test 1 -eq "$(git ls-files -u one | wc -l)" && test 2 -eq "$(git ls-files -u one | wc -l)" &&
test 1 -eq "$(git ls-files -u two | wc -l)" && test 2 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet && test_must_fail git diff --quiet &&
test 4 -eq $(find . | grep -v .git | wc -l) && test 3 -eq $(find . | grep -v .git | wc -l) &&
test_path_is_dir one && test_path_is_file one &&
test_path_is_file one~rename-two && test_path_is_file two &&
test_path_is_file two && test "other" = $(cat one) &&
test "other" = $(cat one~rename-two) && test "stuff" = $(cat two)
test "stuff" = $(cat two) '
' else
test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
git checkout -q rename-one^0 &&
mkdir one &&
test_must_fail git merge --strategy=recursive rename-two &&
test 2 -eq "$(git ls-files -u | wc -l)" &&
test 1 -eq "$(git ls-files -u one | wc -l)" &&
test 1 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet &&
test 4 -eq $(find . | grep -v .git | wc -l) &&
test_path_is_dir one &&
test_path_is_file one~rename-two &&
test_path_is_file two &&
test "other" = $(cat one~rename-two) &&
test "stuff" = $(cat two)
'
fi
test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean start' ' test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean start' '
git reset --hard && git reset --hard &&
git clean -fdqx && git clean -fdqx &&
test_must_fail git merge --strategy=recursive rename-two && test_must_fail git merge --strategy=recursive rename-two &&
test 2 -eq "$(git ls-files -u | wc -l)" && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test 1 -eq "$(git ls-files -u one | wc -l)" && then
test 1 -eq "$(git ls-files -u two | wc -l)" && test 4 -eq "$(git ls-files -u | wc -l)" &&
test 2 -eq "$(git ls-files -u one | wc -l)" &&
test 2 -eq "$(git ls-files -u two | wc -l)"
else
test 2 -eq "$(git ls-files -u | wc -l)" &&
test 1 -eq "$(git ls-files -u one | wc -l)" &&
test 1 -eq "$(git ls-files -u two | wc -l)"
fi &&
test_must_fail git diff --quiet && test_must_fail git diff --quiet &&
@ -572,12 +626,22 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
git checkout -q first-rename^0 && git checkout -q first-rename^0 &&
test_must_fail git merge --strategy=recursive second-rename && test_must_fail git merge --strategy=recursive second-rename &&
test 5 -eq "$(git ls-files -s | wc -l)" && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test 3 -eq "$(git ls-files -u | wc -l)" && then
test 1 -eq "$(git ls-files -u one | wc -l)" && test 5 -eq "$(git ls-files -s | wc -l)" &&
test 1 -eq "$(git ls-files -u two | wc -l)" && test 3 -eq "$(git ls-files -u | wc -l)" &&
test 1 -eq "$(git ls-files -u original | wc -l)" && test 1 -eq "$(git ls-files -u one~HEAD | wc -l)" &&
test 2 -eq "$(git ls-files -o | wc -l)" && test 1 -eq "$(git ls-files -u two~second-rename | wc -l)" &&
test 1 -eq "$(git ls-files -u original | wc -l)" &&
test 0 -eq "$(git ls-files -o | wc -l)"
else
test 5 -eq "$(git ls-files -s | wc -l)" &&
test 3 -eq "$(git ls-files -u | wc -l)" &&
test 1 -eq "$(git ls-files -u one | wc -l)" &&
test 1 -eq "$(git ls-files -u two | wc -l)" &&
test 1 -eq "$(git ls-files -u original | wc -l)" &&
test 2 -eq "$(git ls-files -o | wc -l)"
fi &&
test_path_is_file one/file && test_path_is_file one/file &&
test_path_is_file two/file && test_path_is_file two/file &&

Просмотреть файл

@ -118,12 +118,22 @@ test_expect_success 'mark rename/delete as unmerged' '
test_tick && test_tick &&
git commit -m rename && git commit -m rename &&
test_must_fail git merge delete && test_must_fail git merge delete &&
test 1 = $(git ls-files --unmerged | wc -l) && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 2 = $(git ls-files --unmerged | wc -l)
else
test 1 = $(git ls-files --unmerged | wc -l)
fi &&
git rev-parse --verify :2:a2 && git rev-parse --verify :2:a2 &&
test_must_fail git rev-parse --verify :3:a2 && test_must_fail git rev-parse --verify :3:a2 &&
git checkout -f delete && git checkout -f delete &&
test_must_fail git merge rename && test_must_fail git merge rename &&
test 1 = $(git ls-files --unmerged | wc -l) && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test 2 = $(git ls-files --unmerged | wc -l)
else
test 1 = $(git ls-files --unmerged | wc -l)
fi &&
test_must_fail git rev-parse --verify :2:a2 && test_must_fail git rev-parse --verify :2:a2 &&
git rev-parse --verify :3:a2 git rev-parse --verify :3:a2
' '

Просмотреть файл

@ -3,6 +3,7 @@
test_description='recursive merge corner cases involving criss-cross merges' test_description='recursive merge corner cases involving criss-cross merges'
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-merge.sh
# #
# L1 L2 # L1 L2
@ -537,9 +538,15 @@ test_expect_success 'setup differently handled merges of directory/file conflict
git checkout B^0 && git checkout B^0 &&
test_must_fail git merge C^0 && test_must_fail git merge C^0 &&
git clean -fd && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
git rm -rf a/ && then
git rm a && 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 cat-file -p B:a >a2 &&
git add a2 && git add a2 &&
git commit -m D2 && git commit -m D2 &&
@ -558,7 +565,12 @@ test_expect_success 'setup differently handled merges of directory/file conflict
git checkout C^0 && git checkout C^0 &&
test_must_fail git merge B^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/ && git rm -rf a/ &&
test_write_lines 1 2 3 4 5 6 7 8 >a && test_write_lines 1 2 3 4 5 6 7 8 >a &&
git add a && git add a &&
@ -567,9 +579,15 @@ test_expect_success 'setup differently handled merges of directory/file conflict
git checkout C^0 && git checkout C^0 &&
test_must_fail git merge B^0 && test_must_fail git merge B^0 &&
git clean -fd && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
git rm -rf a/ && then
git rm a && 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 && test_write_lines 1 2 3 4 5 6 7 8 >a2 &&
git add a2 && git add a2 &&
git commit -m E4 && git commit -m E4 &&
@ -587,18 +605,34 @@ test_expect_success 'merge of D1 & E1 fails but has appropriate contents' '
test_must_fail git merge -s recursive E1^0 && test_must_fail git merge -s recursive E1^0 &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 2 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 1 out && test_line_count = 3 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 2 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >expect \ git rev-parse >expect \
A:ignore-me B:a && A:ignore-me B:a D1:a &&
git rev-parse >actual \ git rev-parse >actual \
:0:ignore-me :2:a && :0:ignore-me :1:a :2:a &&
test_cmp expect actual 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 +646,34 @@ test_expect_success 'merge of E1 & D1 fails but has appropriate contents' '
test_must_fail git merge -s recursive D1^0 && test_must_fail git merge -s recursive D1^0 &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 2 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 1 out && test_line_count = 3 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 2 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >expect \ git rev-parse >expect \
A:ignore-me B:a && A:ignore-me B:a D1:a &&
git rev-parse >actual \ git rev-parse >actual \
:0:ignore-me :3:a && :0:ignore-me :1:a :3:a &&
test_cmp expect actual 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 +687,32 @@ test_expect_success 'merge of D1 & E2 fails but has appropriate contents' '
test_must_fail git merge -s recursive E2^0 && test_must_fail git merge -s recursive E2^0 &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 4 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 3 out && test_line_count = 5 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 4 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >expect \ git rev-parse >expect \
B:a E2:a/file C:a/file A:ignore-me && B:a D1:a E2:a/file C:a/file A:ignore-me &&
git rev-parse >actual \ git rev-parse >actual \
:2:a :3:a/file :1:a/file :0:ignore-me && :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_cmp expect actual &&
test_path_is_file a~HEAD test_path_is_file a~HEAD
@ -664,17 +729,32 @@ test_expect_success 'merge of E2 & D1 fails but has appropriate contents' '
test_must_fail git merge -s recursive D1^0 && test_must_fail git merge -s recursive D1^0 &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 4 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 3 out && test_line_count = 5 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 4 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >expect \ git rev-parse >expect \
B:a E2:a/file C:a/file A:ignore-me && B:a D1:a E2:a/file C:a/file A:ignore-me &&
git rev-parse >actual \ git rev-parse >actual \
:3:a :2:a/file :1:a/file :0:ignore-me && :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_cmp expect actual &&
test_path_is_file a~D1^0 test_path_is_file a~D1^0
@ -706,7 +786,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 reset --hard" &&
test_when_finished "git -C directory-file clean -fdqx" && test_when_finished "git -C directory-file clean -fdqx" &&
( (
@ -724,7 +804,7 @@ test_expect_success 'merge of D1 & E4 notifies user a and a2 are related' '
test_line_count = 1 out && test_line_count = 1 out &&
git rev-parse >expect \ 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 \ git rev-parse >actual \
:0:ignore-me :1:a~Temporary\ merge\ branch\ 2 :2:a :3:a2 && :0:ignore-me :1:a~Temporary\ merge\ branch\ 2 :2:a :3:a2 &&
test_cmp expect actual test_cmp expect actual
@ -1069,7 +1149,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 && cd symlink-modify-modify &&
@ -1135,7 +1215,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 && cd symlink-add-add &&
@ -1223,7 +1303,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 && cd submodule-modify-modify &&
@ -1311,7 +1391,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 && cd submodule-add-add &&
@ -1386,7 +1466,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 && cd submodule-symlink-add-add &&

Просмотреть файл

@ -4,6 +4,7 @@ test_description="recursive merge corner cases w/ renames but not criss-crosses"
# t6036 has corner cases that involve both criss-cross merges and renames # t6036 has corner cases that involve both criss-cross merges and renames
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-merge.sh
test_setup_rename_delete_untracked () { test_setup_rename_delete_untracked () {
test_create_repo rename-delete-untracked && test_create_repo rename-delete-untracked &&
@ -312,15 +313,18 @@ test_expect_success 'rename/directory conflict + clean content merge' '
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 1 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 2 out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_line_count = 1 out
else
test_line_count = 2 out
fi &&
echo 0 >expect && echo 0 >expect &&
git cat-file -p base:file >>expect && git cat-file -p base:file >>expect &&
echo 7 >>expect && echo 7 >>expect &&
test_cmp expect newfile~HEAD && test_cmp expect newfile~HEAD &&
test $(git rev-parse :2:newfile) = $(git hash-object expect) &&
test_path_is_file newfile/realfile && test_path_is_file newfile/realfile &&
test_path_is_file newfile~HEAD test_path_is_file newfile~HEAD
) )
@ -343,7 +347,12 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 3 out && test_line_count = 3 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 2 out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_line_count = 1 out
else
test_line_count = 2 out
fi &&
git cat-file -p left-conflict:newfile >left && git cat-file -p left-conflict:newfile >left &&
git cat-file -p base:file >base && git cat-file -p base:file >base &&
@ -355,10 +364,16 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
left base right && left base right &&
test_cmp left newfile~HEAD && test_cmp left newfile~HEAD &&
git rev-parse >expect \ git rev-parse >expect \
base:file left-conflict:newfile right:file && base:file left-conflict:newfile right:file &&
git rev-parse >actual \ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
:1:newfile :2:newfile :3:newfile && then
git rev-parse >actual \
:1:newfile~HEAD :2:newfile~HEAD :3:newfile~HEAD
else
git rev-parse >actual \
:1:newfile :2:newfile :3:newfile
fi &&
test_cmp expect actual && test_cmp expect actual &&
test_path_is_file newfile/realfile && test_path_is_file newfile/realfile &&
@ -878,7 +893,7 @@ test_setup_rad () {
) )
} }
test_expect_failure 'rad-check: rename/add/delete conflict' ' test_expect_merge_algorithm failure success 'rad-check: rename/add/delete conflict' '
test_setup_rad && test_setup_rad &&
( (
cd rad && cd rad &&
@ -951,7 +966,7 @@ test_setup_rrdd () {
) )
} }
test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' ' test_expect_merge_algorithm failure success 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
test_setup_rrdd && test_setup_rrdd &&
( (
cd rrdd && cd rrdd &&
@ -1040,7 +1055,7 @@ test_setup_mod6 () {
) )
} }
test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' ' test_expect_merge_algorithm failure success 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' '
test_setup_mod6 && test_setup_mod6 &&
( (
cd mod6 && cd mod6 &&

Просмотреть файл

@ -26,6 +26,7 @@ test_description="recursive merge with directory renames"
# files that might be renamed into each other's paths.) # files that might be renamed into each other's paths.)
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-merge.sh
########################################################################### ###########################################################################
@ -301,11 +302,20 @@ test_expect_success '1d: Directory renames cause a rename/rename(2to1) conflict'
git cat-file -p :2:x/wham >expect && git cat-file -p :2:x/wham >expect &&
git cat-file -p :3:x/wham >other && git cat-file -p :3:x/wham >other &&
>empty && >empty &&
test_must_fail git merge-file \ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
-L "HEAD" \ then
-L "" \ test_must_fail git merge-file \
-L "B^0" \ -L "HEAD:y/wham" \
expect empty other && -L "" \
-L "B^0:z/wham" \
expect empty other
else
test_must_fail git merge-file \
-L "HEAD" \
-L "" \
-L "B^0" \
expect empty other
fi &&
test_cmp expect x/wham test_cmp expect x/wham
) )
' '
@ -1176,10 +1186,18 @@ test_expect_success '5d: Directory/file/file conflict due to directory rename' '
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 1 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 2 out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_line_count = 1 out &&
git rev-parse >actual \ git rev-parse >actual \
:0:y/b :0:y/c :0:z/d :0:y/f :2:y/d :0:y/d/e && :0:y/b :0:y/c :0:z/d :0:y/f :2:y/d~HEAD :0:y/d/e
else
test_line_count = 2 out &&
git rev-parse >actual \
:0:y/b :0:y/c :0:z/d :0:y/f :2:y/d :0:y/d/e
fi &&
git rev-parse >expect \ git rev-parse >expect \
O:z/b O:z/c B:z/d B:z/f A:y/d B:y/d/e && O:z/b O:z/c B:z/d B:z/f A:y/d B:y/d/e &&
test_cmp expect actual && test_cmp expect actual &&
@ -1262,17 +1280,32 @@ test_expect_success '6a: Tricky rename/delete' '
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && 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_i18ngrep "CONFLICT (rename/delete).*z/c.*y/c" out &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 2 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 1 out && test_line_count = 3 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 2 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >actual \ git rev-parse >actual \
:0:y/b :3:y/c && :0:y/b :1:y/c :3:y/c &&
git rev-parse >expect \ git rev-parse >expect \
O:z/b O:z/c && O:z/b O:z/c O:z/c
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 >actual \
:0:y/b :3:y/c &&
git rev-parse >expect \
O:z/b O:z/c
fi &&
test_cmp expect actual test_cmp expect actual
) )
' '
@ -1339,7 +1372,7 @@ test_setup_6b1 () {
) )
} }
test_expect_failure '6b1: Same renames done on both sides, plus another rename' ' test_expect_merge_algorithm failure success '6b1: Same renames done on both sides, plus another rename' '
test_setup_6b1 && test_setup_6b1 &&
( (
cd 6b1 && cd 6b1 &&
@ -1412,7 +1445,7 @@ test_setup_6b2 () {
) )
} }
test_expect_failure '6b2: Same rename done on both sides' ' test_expect_merge_algorithm failure success '6b2: Same rename done on both sides' '
test_setup_6b2 && test_setup_6b2 &&
( (
cd 6b2 && cd 6b2 &&
@ -1799,11 +1832,20 @@ test_expect_success '7b: rename/rename(2to1), but only due to transitive rename'
git cat-file -p :2:y/d >expect && git cat-file -p :2:y/d >expect &&
git cat-file -p :3:y/d >other && git cat-file -p :3:y/d >other &&
>empty && >empty &&
test_must_fail git merge-file \ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
-L "HEAD" \ then
-L "" \ test_must_fail git merge-file \
-L "B^0" \ -L "HEAD:y/d" \
expect empty other && -L "" \
-L "B^0:z/d" \
expect empty other
else
test_must_fail git merge-file \
-L "HEAD" \
-L "" \
-L "B^0" \
expect empty other
fi &&
test_cmp expect y/d test_cmp expect y/d
) )
' '
@ -1925,17 +1967,32 @@ test_expect_success '7d: transitive rename involved in rename/delete; how is it
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && 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_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 3 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 1 out && test_line_count = 4 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 1 out && test_line_count = 2 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >actual \ git rev-parse >actual \
:0:y/b :0:y/c :3:y/d && :0:y/b :0:y/c :1:y/d :3:y/d &&
git rev-parse >expect \ git rev-parse >expect \
O:z/b O:z/c O:x/d && O:z/b O:z/c O:x/d O:x/d
else
git ls-files -s >out &&
test_line_count = 3 out &&
git ls-files -u >out &&
test_line_count = 1 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >actual \
:0:y/b :0:y/c :3:y/d &&
git rev-parse >expect \
O:z/b O:z/c O:x/d
fi &&
test_cmp expect actual test_cmp expect actual
) )
' '
@ -2016,17 +2073,32 @@ test_expect_success '7e: transitive rename in rename/delete AND dirs in the way'
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out && 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_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out &&
git ls-files -s >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_line_count = 5 out && then
git ls-files -u >out && git ls-files -s >out &&
test_line_count = 1 out && test_line_count = 6 out &&
git ls-files -o >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 2 out &&
git ls-files -o >out &&
test_line_count = 1 out &&
git rev-parse >actual \ git rev-parse >actual \
:0:x/d/f :0:y/d/g :0:y/b :0:y/c :3:y/d && :0:x/d/f :0:y/d/g :0:y/b :0:y/c :1:y/d~B^0 :3:y/d~B^0 &&
git rev-parse >expect \ git rev-parse >expect \
A:x/d/f A:y/d/g O:z/b O:z/c O:x/d && A:x/d/f A:y/d/g O:z/b O:z/c O:x/d O:x/d
else
git ls-files -s >out &&
test_line_count = 5 out &&
git ls-files -u >out &&
test_line_count = 1 out &&
git ls-files -o >out &&
test_line_count = 2 out &&
git rev-parse >actual \
:0:x/d/f :0:y/d/g :0:y/b :0:y/c :3:y/d &&
git rev-parse >expect \
A:x/d/f A:y/d/g O:z/b O:z/c O:x/d
fi &&
test_cmp expect actual && test_cmp expect actual &&
git hash-object y/d~B^0 >actual && git hash-object y/d~B^0 >actual &&
@ -3142,6 +3214,7 @@ test_expect_success '10a: Overwrite untracked with normal rename/delete' '
echo important >z/d && echo important >z/d &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && 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_i18ngrep "The following untracked working tree files would be overwritten by merge" err &&
git ls-files -s >out && git ls-files -s >out &&
@ -3211,21 +3284,34 @@ test_expect_success '10b: Overwrite untracked with dir rename + delete' '
echo contents >y/e && echo contents >y/e &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/delete).*Version B\^0 of y/d left in tree at y/d~B\^0" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Error: Refusing to lose untracked file at y/e; writing to y/e~B\^0 instead" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 3 out && test_line_count = 1 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 0 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 5 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 &&
git rev-parse >actual \ git ls-files -s >out &&
:0:y/b :3:y/d :3:y/e && test_line_count = 3 out &&
git rev-parse >expect \ git ls-files -u >out &&
O:z/b O:z/c B:z/e && test_line_count = 2 out &&
test_cmp expect actual && git ls-files -o >out &&
test_line_count = 5 out &&
git rev-parse >actual \
:0:y/b :3:y/d :3:y/e &&
git rev-parse >expect \
O:z/b O:z/c B:z/e &&
test_cmp expect actual
fi &&
echo very >expect && echo very >expect &&
test_cmp expect y/c && test_cmp expect y/c &&
@ -3288,25 +3374,38 @@ test_expect_success '10c1: Overwrite untracked with dir rename/rename(1to2)' '
echo important >y/c && echo important >y/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/rename)" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~B\^0 instead" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 6 out && test_line_count = 4 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 3 out && test_line_count = 0 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 3 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 &&
git rev-parse >actual \ git ls-files -s >out &&
:0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :3:y/c && test_line_count = 6 out &&
git rev-parse >expect \ git ls-files -u >out &&
O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c && test_line_count = 3 out &&
test_cmp expect actual && git ls-files -o >out &&
test_line_count = 3 out &&
git hash-object y/c~B^0 >actual && git rev-parse >actual \
git rev-parse O:x/c >expect && :0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :3:y/c &&
test_cmp expect actual && 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~B^0 >actual &&
git rev-parse O:x/c >expect &&
test_cmp expect actual
fi &&
echo important >expect && echo important >expect &&
test_cmp expect y/c test_cmp expect y/c
@ -3326,25 +3425,38 @@ test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), oth
echo important >y/c && echo important >y/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/rename)" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 6 out && test_line_count = 4 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 3 out && test_line_count = 0 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 3 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 &&
git rev-parse >actual \ git ls-files -s >out &&
:0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c && test_line_count = 6 out &&
git rev-parse >expect \ git ls-files -u >out &&
O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c && test_line_count = 3 out &&
test_cmp expect actual && git ls-files -o >out &&
test_line_count = 3 out &&
git hash-object y/c~HEAD >actual && git rev-parse >actual \
git rev-parse O:x/c >expect && :0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c &&
test_cmp expect actual && 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
fi &&
echo important >expect && echo important >expect &&
test_cmp expect y/c test_cmp expect y/c
@ -3402,37 +3514,50 @@ test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' '
echo important >y/wham && echo important >y/wham &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/rename)" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose untracked file at y/wham" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 6 out && test_line_count = 6 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 0 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 3 out && test_line_count = 3 out
else
test_i18ngrep "CONFLICT (rename/rename)" out &&
test_i18ngrep "Refusing to lose untracked file at y/wham" out &&
git rev-parse >actual \ git ls-files -s >out &&
:0:y/a :0:y/b :0:y/d :0:y/e :2:y/wham :3:y/wham && test_line_count = 6 out &&
git rev-parse >expect \ git ls-files -u >out &&
O:z/a O:z/b O:x/d O:x/e O:z/c O:x/f && test_line_count = 2 out &&
test_cmp expect actual && git ls-files -o >out &&
test_line_count = 3 out &&
test_must_fail git rev-parse :1:y/wham && git rev-parse >actual \
:0:y/a :0:y/b :0:y/d :0:y/e :2:y/wham :3:y/wham &&
git rev-parse >expect \
O:z/a O:z/b O:x/d O:x/e O:z/c O:x/f &&
test_cmp expect actual &&
test_must_fail git rev-parse :1:y/wham &&
# Test that 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
fi &&
echo important >expect && echo important >expect &&
test_cmp expect y/wham && test_cmp expect y/wham
# 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
) )
' '
@ -3471,7 +3596,7 @@ test_setup_10e () {
) )
} }
test_expect_failure '10e: Does git complain about untracked file that is not really in the way?' ' test_expect_merge_algorithm failure success '10e: Does git complain about untracked file that is not really in the way?' '
test_setup_10e && test_setup_10e &&
( (
cd 10e && cd 10e &&
@ -3562,28 +3687,35 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' '
echo stuff >>z/c && echo stuff >>z/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "Refusing to lose dirty file at z/c" out && 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
else
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
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 = 3 out &&
git rev-parse >actual \
:0:z/a :2:z/c &&
git rev-parse >expect \
O:z/a B:z/b &&
test_cmp expect actual &&
git hash-object z/c~HEAD >actual &&
git rev-parse B:z/b >expect &&
test_cmp expect actual
fi &&
test_seq 1 10 >expected && test_seq 1 10 >expected &&
echo stuff >>expected && echo stuff >>expected &&
test_cmp expected z/c && test_cmp expected z/c
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 = 4 out &&
git rev-parse >actual \
:0:z/a :2:z/c &&
git rev-parse >expect \
O:z/a B:z/b &&
test_cmp expect actual &&
git hash-object z/c~HEAD >actual &&
git rev-parse B:z/b >expect &&
test_cmp expect actual
) )
' '
@ -3634,32 +3766,39 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename'
git checkout A^0 && git checkout A^0 &&
echo stuff >>z/c && echo stuff >>z/c &&
git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose dirty file at z/c" out && 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
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 &&
git ls-files -s >out &&
test_line_count = 3 out &&
git ls-files -u >out &&
test_line_count = 0 out &&
git ls-files -m >out &&
test_line_count = 0 out &&
git ls-files -o >out &&
test_line_count = 3 out &&
git rev-parse >actual \
:0:x/b :0:y/a :0:y/c &&
git rev-parse >expect \
O:x/b O:z/a B:x/c &&
test_cmp expect actual &&
git hash-object y/c >actual &&
git rev-parse B:x/c >expect &&
test_cmp expect actual
fi &&
grep -q stuff z/c && grep -q stuff z/c &&
test_seq 1 10 >expected && test_seq 1 10 >expected &&
echo stuff >>expected && echo stuff >>expected &&
test_cmp expected z/c && test_cmp expected z/c
git ls-files -s >out &&
test_line_count = 3 out &&
git ls-files -u >out &&
test_line_count = 0 out &&
git ls-files -m >out &&
test_line_count = 0 out &&
git ls-files -o >out &&
test_line_count = 4 out &&
git rev-parse >actual \
:0:x/b :0:y/a :0:y/c &&
git rev-parse >expect \
O:x/b O:z/a B:x/c &&
test_cmp expect actual &&
git hash-object y/c >actual &&
git rev-parse B:x/c >expect &&
test_cmp expect actual
) )
' '
@ -3711,7 +3850,13 @@ test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict'
echo stuff >>y/c && echo stuff >>y/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "following files would be overwritten by merge" err && 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
else
test_i18ngrep "following files would be overwritten by merge" err
fi &&
grep -q stuff y/c && grep -q stuff y/c &&
test_seq 1 10 >expected && test_seq 1 10 >expected &&
@ -3779,29 +3924,35 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict'
echo stuff >>z/c && echo stuff >>z/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "Refusing to lose dirty file at z/c" out && 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
else
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
git ls-files -s >out &&
test_line_count = 4 out &&
git ls-files -u >out &&
test_line_count = 1 out &&
git ls-files -o >out &&
test_line_count = 4 out &&
git rev-parse >actual \
:0:x/b :0:y/a :0:y/c/d :3:y/c &&
git rev-parse >expect \
O:x/b O:z/a B:y/c/d B:x/c &&
test_cmp expect actual &&
git hash-object y/c~HEAD >actual &&
git rev-parse B:x/c >expect &&
test_cmp expect actual
fi &&
grep -q stuff z/c && grep -q stuff z/c &&
test_seq 1 10 >expected && test_seq 1 10 >expected &&
echo stuff >>expected && echo stuff >>expected &&
test_cmp expected z/c && test_cmp expected z/c
git ls-files -s >out &&
test_line_count = 4 out &&
git ls-files -u >out &&
test_line_count = 1 out &&
git ls-files -o >out &&
test_line_count = 5 out &&
git rev-parse >actual \
:0:x/b :0:y/a :0:y/c/d :3:y/c &&
git rev-parse >expect \
O:x/b O:z/a B:y/c/d B:x/c &&
test_cmp expect actual &&
git hash-object y/c~HEAD >actual &&
git rev-parse B:x/c >expect &&
test_cmp expect actual
) )
' '
@ -3859,37 +4010,43 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to
echo mods >>y/c && echo mods >>y/c &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/rename)" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose dirty file at y/c" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "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 &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 7 out && test_line_count = 7 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 4 out && test_line_count = 4 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 3 out && test_line_count = 3 out &&
git rev-parse >actual \
:0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
git rev-parse >expect \
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 &&
# 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
fi &&
echo different >expected && echo different >expected &&
echo mods >>expected && echo mods >>expected &&
test_cmp expected y/c && test_cmp expected y/c
git rev-parse >actual \
:0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
git rev-parse >expect \
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 &&
# 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
) )
' '
@ -3942,38 +4099,44 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
echo important >>y/wham && echo important >>y/wham &&
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/rename)" out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose dirty file at y/wham" out && then
test_path_is_missing .git/MERGE_HEAD &&
test_i18ngrep "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 &&
git ls-files -s >out && git ls-files -s >out &&
test_line_count = 4 out && test_line_count = 4 out &&
git ls-files -u >out && git ls-files -u >out &&
test_line_count = 2 out && test_line_count = 2 out &&
git ls-files -o >out && git ls-files -o >out &&
test_line_count = 3 out && test_line_count = 3 out &&
test_must_fail git rev-parse :1:y/wham &&
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 that 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
fi &&
test_seq 1 10 >expected && test_seq 1 10 >expected &&
echo important >>expected && echo important >>expected &&
test_cmp expected y/wham && test_cmp expected y/wham
test_must_fail git rev-parse :1:y/wham &&
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 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
) )
' '
@ -4104,7 +4267,7 @@ test_setup_12b1 () {
) )
} }
test_expect_failure '12b1: Moving two directory hierarchies into each other' ' test_expect_merge_algorithm failure success '12b1: Moving two directory hierarchies into each other' '
test_setup_12b1 && test_setup_12b1 &&
( (
cd 12b1 && cd 12b1 &&
@ -4272,7 +4435,7 @@ test_setup_12c1 () {
) )
} }
test_expect_failure '12c1: Moving one directory hierarchy into another w/ content merge' ' test_expect_merge_algorithm failure success '12c1: Moving one directory hierarchy into another w/ content merge' '
test_setup_12c1 && test_setup_12c1 &&
( (
cd 12c1 && cd 12c1 &&
@ -4562,20 +4725,22 @@ test_expect_success '12e: Rename/merge subdir into the root, variant 2' '
# folder/subdir/newsubdir/e_Merge2 # folder/subdir/newsubdir/e_Merge2
# folder/subdir/tweaked/{h,Makefile_SUB_Merge1,newfile.py} # folder/subdir/tweaked/{h,Makefile_SUB_Merge1,newfile.py}
# folder/unchanged/<LOTS OF FILES> # folder/unchanged/<LOTS OF FILES>
# # Things being checked here:
# Notes: This testcase happens to exercise lots of the # 1. dir/subdir/newfile.c does not get pushed into folder/subdir/newsubdir/.
# optimization-specific codepaths in merge-ort, and also # dir/subdir/{a,b,c,d} -> folder/subdir/{a,b,c,d} looks like
# demonstrated a failing of the directory rename detection algorithm # dir/ -> folder/,
# in merge-recursive; newfile.c should not get pushed into # whereas dir/subdir/e -> folder/subdir/newsubdir/e looks like
# folder/subdir/newsubdir/, yet merge-recursive put it there because # dir/subdir/ -> folder/subdir/newsubdir/
# the rename of dir/subdir/{a,b,c,d} -> folder/subdir/{a,b,c,d} # and if we note that newfile.c is found in dir/subdir/, we might overlook
# looks like # the dir/ -> folder/ rule that has more weight. Older git versions did
# dir/ -> folder/, # this.
# whereas the rename of dir/subdir/e -> folder/subdir/newsubdir/e # 2. The code to do trivial directory resolves. Note that
# looks like # dir/subdir/unchanged/ is unchanged and can be deleted, and files in the
# dir/subdir/ -> folder/subdir/newsubdir/ # new folder/subdir/unchanged/ are not needed as a target to any renames.
# and if we note that newfile.c is found in dir/subdir/, we might # Thus, in the second collect_merge_info_callback() we can just resolve
# overlook the dir/ -> folder/ rule that has more weight. # these two directories trivially without recursing.)
# 3. Exercising the codepaths for caching renames and deletes from one cherry
# pick and re-applying them in the subsequent one.
test_setup_12f () { test_setup_12f () {
test_create_repo 12f && test_create_repo 12f &&
@ -4632,7 +4797,7 @@ test_setup_12f () {
) )
} }
test_expect_failure '12f: Trivial directory resolve, caching, all kinds of fun' ' test_expect_merge_algorithm failure success '12f: Trivial directory resolve, caching, all kinds of fun' '
test_setup_12f && test_setup_12f &&
( (
cd 12f && cd 12f &&
@ -4640,7 +4805,7 @@ test_expect_failure '12f: Trivial directory resolve, caching, all kinds of fun'
git checkout A^0 && git checkout A^0 &&
git branch Bmod B && git branch Bmod B &&
git -c merge.directoryRenames=true rebase A Bmod && GIT_TRACE2_PERF="$(pwd)/trace.output" git -c merge.directoryRenames=true rebase A Bmod &&
echo Checking the pick of B1... && echo Checking the pick of B1... &&
@ -4721,7 +4886,12 @@ test_expect_failure '12f: Trivial directory resolve, caching, all kinds of fun'
test_seq 2 12 >e_Merge2 && test_seq 2 12 >e_Merge2 &&
git hash-object e_Merge2 >expect && git hash-object e_Merge2 >expect &&
git rev-parse Bmod:folder/subdir/newsubdir/e >actual && git rev-parse Bmod:folder/subdir/newsubdir/e >actual &&
test_cmp expect actual test_cmp expect actual &&
grep region_enter.*collect_merge_info trace.output >collect &&
test_line_count = 4 collect &&
grep region_enter.*process_entries$ trace.output >process &&
test_line_count = 2 process
) )
' '

Просмотреть файл

@ -23,6 +23,7 @@ test_description="merge cases"
# files that might be renamed into each other's paths.) # files that might be renamed into each other's paths.)
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-merge.sh
########################################################################### ###########################################################################
@ -666,7 +667,7 @@ test_setup_4a () {
# correct requires doing the merge in-memory first, then realizing that no # correct requires doing the merge in-memory first, then realizing that no
# updates to the file are necessary, and thus that we can just leave the path # updates to the file are necessary, and thus that we can just leave the path
# alone. # alone.
test_expect_failure '4a: Change on A, change on B subset of A, dirty mods present' ' test_expect_merge_algorithm failure success '4a: Change on A, change on B subset of A, dirty mods present' '
test_setup_4a && test_setup_4a &&
( (
cd 4a && cd 4a &&

Просмотреть файл

@ -3,6 +3,7 @@
test_description='merge-recursive backend test' test_description='merge-recursive backend test'
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-merge.sh
test_expect_success 'setup 1' ' test_expect_success 'setup 1' '
@ -641,7 +642,7 @@ test_expect_success 'merge-recursive copy vs. rename' '
test_cmp expected actual test_cmp expected actual
' '
test_expect_failure 'merge-recursive rename vs. rename/symlink' ' test_expect_merge_algorithm failure success 'merge-recursive rename vs. rename/symlink' '
git checkout -f rename && git checkout -f rename &&
git merge rename-ln && git merge rename-ln &&

Просмотреть файл

@ -97,11 +97,19 @@ test_expect_success 'will not overwrite unstaged changes in renamed file' '
git mv c1.c other.c && git mv c1.c other.c &&
git commit -m rename && git commit -m rename &&
cp important other.c && cp important other.c &&
test_must_fail git merge c1a >out && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
test_i18ngrep "Refusing to lose dirty file at other.c" out && then
test_path_is_file other.c~HEAD && test_must_fail git merge c1a >out 2>err &&
test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) && test_i18ngrep "would be overwritten by merge" err &&
test_cmp important other.c test_cmp important other.c &&
test_path_is_missing .git/MERGE_HEAD
else
test_must_fail git merge c1a >out &&
test_i18ngrep "Refusing to lose dirty file at other.c" out &&
test_path_is_file other.c~HEAD &&
test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) &&
test_cmp important other.c
fi
' '
test_expect_success 'will not overwrite untracked subtree' ' test_expect_success 'will not overwrite untracked subtree' '

Просмотреть файл

@ -127,7 +127,12 @@ test_expect_success 'merging should conflict for non fast-forward' '
git checkout -b test-nonforward b && git checkout -b test-nonforward b &&
(cd sub && (cd sub &&
git rev-parse sub-d > ../expect) && git rev-parse sub-d > ../expect) &&
test_must_fail git merge c 2> actual && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_must_fail git merge c >actual
else
test_must_fail git merge c 2> actual
fi &&
grep $(cat expect) actual > /dev/null && grep $(cat expect) actual > /dev/null &&
git reset --hard) git reset --hard)
' '
@ -138,9 +143,21 @@ test_expect_success 'merging should fail for ambiguous common parent' '
(cd sub && (cd sub &&
git checkout -b ambiguous sub-b && git checkout -b ambiguous sub-b &&
git merge sub-c && git merge sub-c &&
git rev-parse sub-d > ../expect1 && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
git rev-parse ambiguous > ../expect2) && then
test_must_fail git merge c 2> actual && git rev-parse --short sub-d >../expect1 &&
git rev-parse --short ambiguous >../expect2
else
git rev-parse sub-d > ../expect1 &&
git rev-parse ambiguous > ../expect2
fi
) &&
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
test_must_fail git merge c >actual
else
test_must_fail git merge c 2> actual
fi &&
grep $(cat expect1) actual > /dev/null && grep $(cat expect1) actual > /dev/null &&
grep $(cat expect2) actual > /dev/null && grep $(cat expect2) actual > /dev/null &&
git reset --hard) git reset --hard)

Просмотреть файл

@ -77,6 +77,12 @@ Merge made by the 'recursive' strategy.
EOF EOF
test_expect_success 'merge reduces irrelevant remote heads' ' test_expect_success 'merge reduces irrelevant remote heads' '
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
mv expected expected.tmp &&
sed s/recursive/ort/ expected.tmp >expected &&
rm expected.tmp
fi &&
GIT_MERGE_VERBOSITY=0 git merge c4 c5 >actual && GIT_MERGE_VERBOSITY=0 git merge c4 c5 >actual &&
test_i18ncmp expected actual test_i18ncmp expected actual
' '

Просмотреть файл

@ -532,7 +532,14 @@ test_expect_success 'file vs modified submodule' '
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
yes "" | git mergetool both && yes "" | git mergetool both &&
yes "d" | git mergetool file11 file12 && yes "d" | git mergetool file11 file12 &&
yes "l" | git mergetool submod && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
yes "c" | git mergetool submod~HEAD &&
git rm submod &&
git mv submod~HEAD submod
else
yes "l" | git mergetool submod
fi &&
git submodule update -N && git submodule update -N &&
echo "not a submodule" >expect && echo "not a submodule" >expect &&
test_cmp expect submod && test_cmp expect submod &&
@ -549,7 +556,15 @@ test_expect_success 'file vs modified submodule' '
yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && yes "" | git mergetool file1 file2 spaced\ name subdir/file3 &&
yes "" | git mergetool both && yes "" | git mergetool both &&
yes "d" | git mergetool file11 file12 && yes "d" | git mergetool file11 file12 &&
yes "r" | git mergetool submod && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
mv submod submod.orig &&
git rm --cached submod &&
yes "c" | git mergetool submod~test19 &&
git mv submod~test19 submod
else
yes "r" | git mergetool submod
fi &&
test -d submod.orig && test -d submod.orig &&
git submodule update -N && git submodule update -N &&
echo "not a submodule" >expect && echo "not a submodule" >expect &&
@ -567,6 +582,10 @@ test_expect_success 'file vs modified submodule' '
yes "" | git mergetool both && yes "" | git mergetool both &&
yes "d" | git mergetool file11 file12 && yes "d" | git mergetool file11 file12 &&
yes "l" | git mergetool submod && yes "l" | git mergetool submod &&
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
yes "d" | git mergetool submod~test19
fi &&
echo "master submodule" >expect && echo "master submodule" >expect &&
test_cmp expect submod/bar && test_cmp expect submod/bar &&
git submodule update -N && git submodule update -N &&
@ -664,7 +683,14 @@ test_expect_success 'directory vs modified submodule' '
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
test ! -e submod.orig && test ! -e submod.orig &&
yes "r" | git mergetool submod && if test "$GIT_TEST_MERGE_ALGORITHM" = ort
then
yes "r" | git mergetool submod~master &&
git mv submod submod.orig &&
git mv submod~master submod
else
yes "r" | git mergetool submod
fi &&
test -d submod.orig && test -d submod.orig &&
echo "not a submodule" >expect && echo "not a submodule" >expect &&
test_cmp expect submod.orig/file16 && test_cmp expect submod.orig/file16 &&