Merge branch 'en/merge-tests'

Updates to "git merge" tests, in preparation for a new merge
strategy backend.

* en/merge-tests:
  t6425: be more flexible with rename/delete conflict messages
  t642[23]: be more flexible for add/add conflicts involving pair renames
  t6422, t6426: be more flexible for add/add conflicts involving renames
  t6423: add an explanation about why one of the tests does not pass
  t6416, t6423: clarify some comments and fix some typos
  t6422: fix multiple errors with the mod6 test expectations
  t6423: fix test setup for a couple tests
  t6416, t6422: fix incorrect untracked file count
  t6422: fix bad check against missing file
  t6418: tighten delete/normalize conflict testcase
  Collect merge-related tests to t64xx
This commit is contained in:
Junio C Hamano 2020-08-19 16:14:43 -07:00
commit 36d225c7d4
35 changed files with 71 additions and 48 deletions

View File

@ -452,7 +452,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
#
# So choice 5 at least provides some kind of conflict for the original case,
# and can merge cleanly as expected with D1 and E3. It also made things just
# slightly funny for merging D1 and e$, where E4 is defined as:
# slightly funny for merging D1 and E4, where E4 is defined as:
# Commit E4: Merge B & C, modifying 'a' and renaming to 'a2', and deleting 'a/'
# in this case, we'll get a rename/rename(1to2) conflict because a~$UNIQUE
# gets renamed to 'a' in D1 and to 'a2' in E4. But that's better than having
@ -1144,7 +1144,7 @@ test_expect_failure 'check symlink add/add' '
test_must_fail git merge -s recursive E^0 &&
git ls-files -s >out &&
test_line_count = 2 out &&
test_line_count = 3 out &&
git ls-files -u >out &&
test_line_count = 2 out &&
git ls-files -o >out &&

View File

@ -197,7 +197,8 @@ test_expect_success 'Test delete/normalize conflict' '
git commit -m "remove file" &&
git checkout master &&
git reset --hard a^ &&
git merge side
git merge side &&
test_path_is_missing file
'
test_done

View File

@ -457,7 +457,7 @@ test_expect_success 'handle rename-with-content-merge vs. add' '
git checkout A^0 &&
test_must_fail git merge -s recursive B^0 >out &&
test_i18ngrep "CONFLICT (rename/add)" out &&
test_i18ngrep "CONFLICT (.*/add)" out &&
git ls-files -s >out &&
test_line_count = 2 out &&
@ -503,7 +503,7 @@ test_expect_success 'handle rename-with-content-merge vs. add, merge other way'
git checkout B^0 &&
test_must_fail git merge -s recursive A^0 >out &&
test_i18ngrep "CONFLICT (rename/add)" out &&
test_i18ngrep "CONFLICT (.*/add)" out &&
git ls-files -s >out &&
test_line_count = 2 out &&
@ -583,7 +583,7 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
git checkout B^0 &&
test_must_fail git merge -s recursive C^0 >out &&
test_i18ngrep "CONFLICT (rename/rename)" out &&
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
git ls-files -s >out &&
test_line_count = 2 out &&
@ -886,12 +886,17 @@ test_expect_failure 'rad-check: rename/add/delete conflict' '
git checkout B^0 &&
test_must_fail git merge -s recursive A^0 >out 2>err &&
# Not sure whether the output should contain just one
# "CONFLICT (rename/add/delete)" line, or if it should break
# it into a pair of "CONFLICT (rename/delete)" and
# "CONFLICT (rename/add)"; allow for either.
test_i18ngrep "CONFLICT (rename.*add)" out &&
test_i18ngrep "CONFLICT (rename.*delete)" out &&
# Instead of requiring the output to contain one combined line
# CONFLICT (rename/add/delete)
# or perhaps two lines:
# CONFLICT (rename/add): new file collides with rename target
# CONFLICT (rename/delete): rename source removed on other side
# and instead of requiring "rename/add" instead of "add/add",
# be flexible in the type of console output message(s) reported
# for this particular case; we will be more stringent about the
# contents of the index and working directory.
test_i18ngrep "CONFLICT (.*/add)" out &&
test_i18ngrep "CONFLICT (rename.*/delete)" out &&
test_must_be_empty err &&
git ls-files -s >file_count &&
@ -899,14 +904,14 @@ test_expect_failure 'rad-check: rename/add/delete conflict' '
git ls-files -u >file_count &&
test_line_count = 2 file_count &&
git ls-files -o >file_count &&
test_line_count = 2 file_count &&
test_line_count = 3 file_count &&
git rev-parse >actual \
:2:bar :3:bar &&
git rev-parse >expect \
B:bar A:bar &&
test_cmp file_is_missing foo &&
test_path_is_missing foo &&
# bar should have two-way merged contents of the different
# versions of bar; check that content from both sides is
# present.
@ -954,11 +959,17 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
git checkout A^0 &&
test_must_fail git merge -s recursive B^0 >out 2>err &&
# Not sure whether the output should contain just one
# "CONFLICT (rename/rename/delete/delete)" line, or if it
# should break it into three: "CONFLICT (rename/rename)" and
# two "CONFLICT (rename/delete)" lines; allow for either.
test_i18ngrep "CONFLICT (rename/rename)" out &&
# Instead of requiring the output to contain one combined line
# CONFLICT (rename/rename/delete/delete)
# or perhaps two lines:
# CONFLICT (rename/rename): ...
# CONFLICT (rename/delete): info about pair 1
# CONFLICT (rename/delete): info about pair 2
# and instead of requiring "rename/rename" instead of "add/add",
# be flexible in the type of console output message(s) reported
# for this particular case; we will be more stringent about the
# contents of the index and working directory.
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
test_i18ngrep "CONFLICT (rename.*delete)" out &&
test_must_be_empty err &&
@ -967,15 +978,15 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
git ls-files -u >file_count &&
test_line_count = 2 file_count &&
git ls-files -o >file_count &&
test_line_count = 2 file_count &&
test_line_count = 3 file_count &&
git rev-parse >actual \
:2:baz :3:baz &&
git rev-parse >expect \
O:foo O:bar &&
test_cmp file_is_missing foo &&
test_cmp file_is_missing bar &&
test_path_is_missing foo &&
test_path_is_missing bar &&
# baz should have two-way merged contents of the original
# contents of foo and bar; check that content from both sides
# is present.
@ -1042,25 +1053,25 @@ test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename
test_must_be_empty err &&
git ls-files -s >file_count &&
test_line_count = 6 file_count &&
test_line_count = 9 file_count &&
git ls-files -u >file_count &&
test_line_count = 6 file_count &&
test_line_count = 9 file_count &&
git ls-files -o >file_count &&
test_line_count = 3 file_count &&
test_seq 10 20 >merged-one &&
test_seq 51 60 >merged-five &&
# Determine what the merge of three would give us.
test_seq 30 40 >three-side-A &&
test_seq 31 39 >three-base &&
test_seq 31 40 >three-side-A &&
test_seq 31 39 >three-side-B &&
echo forty >three-side-B &&
>empty &&
echo forty >>three-side-B &&
test_must_fail git merge-file \
-L "HEAD" \
-L "HEAD:four" \
-L "" \
-L "B^0" \
three-side-A empty three-side-B &&
sed -e "s/^\([<=>]\)/\1\1\1/" three-side-A >merged-three &&
-L "B^0:two" \
three-side-A three-base three-side-B &&
sed -e "s/^\([<=>]\)/\1\1/" three-side-A >merged-three &&
# Verify the index is as expected
git rev-parse >actual \
@ -1075,6 +1086,7 @@ test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename
git cat-file -p :2:two >expect &&
git cat-file -p :3:two >other &&
>empty &&
test_must_fail git merge-file \
-L "HEAD" -L "" -L "B^0" \
expect empty other &&

View File

@ -275,7 +275,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 (rename/rename)" out &&
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
git ls-files -s >out &&
test_line_count = 8 out &&
@ -1686,7 +1686,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 (rename/rename)" out &&
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
git ls-files -s >out &&
test_line_count = 4 out &&
@ -2260,24 +2260,23 @@ test_expect_success '8d: rename/delete...or not?' '
# Commit B: w/{b,c}, z/d
#
# Possible Resolutions:
# w/o dir-rename detection: z/d, CONFLICT(z/b -> y/b vs. w/b),
# CONFLICT(z/c -> y/c vs. w/c)
# Currently expected: y/d, CONFLICT(z/b -> y/b vs. w/b),
# CONFLICT(z/c -> y/c vs. w/c)
# Optimal: ??
# if z not considered renamed: z/d, CONFLICT(z/b -> y/b vs. w/b),
# CONFLICT(z/c -> y/c vs. w/c)
# if z->y rename considered: y/d, CONFLICT(z/b -> y/b vs. w/b),
# CONFLICT(z/c -> y/c vs. w/c)
# Optimal: ??
#
# Notes: In commit A, directory z got renamed to y. In commit B, directory z
# did NOT get renamed; the directory is still present; instead it is
# considered to have just renamed a subset of paths in directory z
# elsewhere. Therefore, the directory rename done in commit A to z/
# applies to z/d and maps it to y/d.
# elsewhere. However, this is much like testcase 6b (where commit B
# moves all the original paths out of z/ but opted to keep d
# within z/). This makes it hard to judge where d should end up.
#
# It's possible that users would get confused about this, but what
# should we do instead? Silently leaving at z/d seems just as bad or
# maybe even worse. Perhaps we could print a big warning about z/d
# and how we're moving to y/d in this case, but when I started thinking
# about the ramifications of doing that, I didn't know how to rule out
# that opening other weird edge and corner cases so I just punted.
# should we do instead? It's not at all clear to me whether z/d or
# y/d or something else is a better resolution here, and other cases
# start getting really tricky, so I just picked one.
test_setup_8e () {
test_create_repo 8e &&
@ -2844,6 +2843,14 @@ test_expect_success '9f: Renamed directory that only contained immediate subdirs
# Commit A: priority/{alpha,bravo}/$more_files
# Commit B: goal/{a,b}/$more_files, goal/c
# Expected: priority/{alpha,bravo}/$more_files, priority/c
# We currently fail this test because the directory renames we detect are
# goal/a/ -> priority/alpha/
# goal/b/ -> priority/bravo/
# We do not detect
# goal/ -> priority/
# because of no files found within goal/, and the fact that "a" != "alpha"
# and "b" != "bravo". But I'm not sure it's really a failure given that
# viewpoint...
test_setup_9g () {
test_create_repo 9g &&
@ -2880,6 +2887,7 @@ test_setup_9g () {
}
test_expect_failure '9g: Renamed directory that only contained immediate subdirs, immediate subdirs renamed' '
test_setup_9g &&
(
cd 9g &&
@ -3362,6 +3370,7 @@ test_setup_10e () {
}
test_expect_failure '10e: Does git complain about untracked file that is not really in the way?' '
test_setup_10e &&
(
cd 10e &&
@ -4403,7 +4412,7 @@ test_expect_success '13b(info): messages for transitive rename with conflicted c
# Commit O: z/{b,c}, x/{d,e}
# Commit A: y/{b,c,d}, x/e
# Commit B: z/{b,c,d}, x/e
# Expected: y/{b,c,d}, with info or conflict messages for d (
# Expected: y/{b,c,d}, x/e, with info or conflict messages for d
# A: renamed x/d -> z/d; B: renamed z/ -> y/ AND renamed x/d to y/d
# One could argue A had partial knowledge of what was done with
# d and B had full knowledge, but that's a slippery slope as

View File

@ -17,7 +17,8 @@ test_expect_success 'rename/delete' '
git commit -m "delete" &&
test_must_fail git merge --strategy=recursive rename >output &&
test_i18ngrep "CONFLICT (rename/delete): A deleted in HEAD and renamed to B in rename. Version rename of B left in tree." output
test_i18ngrep "CONFLICT (rename/delete): A.* renamed .*to B.* in rename" output &&
test_i18ngrep "CONFLICT (rename/delete): A.*deleted in HEAD." output
'
test_done

View File

@ -374,7 +374,7 @@ test_expect_success '2c: Modify b & add c VS rename b->c' '
export GIT_MERGE_VERBOSITY &&
test_must_fail git merge -s recursive B^0 >out 2>err &&
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
test_i18ngrep "CONFLICT (.*/add):" out &&
test_must_be_empty err &&
# Make sure c WAS updated