Skip to content

Commit eab9523

Browse files
committed
Merge branch 'en/merge-tests' into next
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
2 parents 9b3c35f + 1f3c9ba commit eab9523

35 files changed

+71
-48
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

t/t6036-recursive-corner-cases.sh renamed to t/t6416-recursive-corner-cases.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
452452
#
453453
# So choice 5 at least provides some kind of conflict for the original case,
454454
# and can merge cleanly as expected with D1 and E3. It also made things just
455-
# slightly funny for merging D1 and e$, where E4 is defined as:
455+
# slightly funny for merging D1 and E4, where E4 is defined as:
456456
# Commit E4: Merge B & C, modifying 'a' and renaming to 'a2', and deleting 'a/'
457457
# in this case, we'll get a rename/rename(1to2) conflict because a~$UNIQUE
458458
# 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' '
11441144
test_must_fail git merge -s recursive E^0 &&
11451145
11461146
git ls-files -s >out &&
1147-
test_line_count = 2 out &&
1147+
test_line_count = 3 out &&
11481148
git ls-files -u >out &&
11491149
test_line_count = 2 out &&
11501150
git ls-files -o >out &&
File renamed without changes.

t/t6038-merge-text-auto.sh renamed to t/t6418-merge-text-auto.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ test_expect_success 'Test delete/normalize conflict' '
197197
git commit -m "remove file" &&
198198
git checkout master &&
199199
git reset --hard a^ &&
200-
git merge side
200+
git merge side &&
201+
test_path_is_missing file
201202
'
202203

203204
test_done
File renamed without changes.

t/t6042-merge-rename-corner-cases.sh renamed to t/t6422-merge-rename-corner-cases.sh

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ test_expect_success 'handle rename-with-content-merge vs. add' '
457457
git checkout A^0 &&
458458
459459
test_must_fail git merge -s recursive B^0 >out &&
460-
test_i18ngrep "CONFLICT (rename/add)" out &&
460+
test_i18ngrep "CONFLICT (.*/add)" out &&
461461
462462
git ls-files -s >out &&
463463
test_line_count = 2 out &&
@@ -503,7 +503,7 @@ test_expect_success 'handle rename-with-content-merge vs. add, merge other way'
503503
git checkout B^0 &&
504504
505505
test_must_fail git merge -s recursive A^0 >out &&
506-
test_i18ngrep "CONFLICT (rename/add)" out &&
506+
test_i18ngrep "CONFLICT (.*/add)" out &&
507507
508508
git ls-files -s >out &&
509509
test_line_count = 2 out &&
@@ -583,7 +583,7 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
583583
git checkout B^0 &&
584584
585585
test_must_fail git merge -s recursive C^0 >out &&
586-
test_i18ngrep "CONFLICT (rename/rename)" out &&
586+
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
587587
588588
git ls-files -s >out &&
589589
test_line_count = 2 out &&
@@ -886,27 +886,32 @@ test_expect_failure 'rad-check: rename/add/delete conflict' '
886886
git checkout B^0 &&
887887
test_must_fail git merge -s recursive A^0 >out 2>err &&
888888
889-
# Not sure whether the output should contain just one
890-
# "CONFLICT (rename/add/delete)" line, or if it should break
891-
# it into a pair of "CONFLICT (rename/delete)" and
892-
# "CONFLICT (rename/add)"; allow for either.
893-
test_i18ngrep "CONFLICT (rename.*add)" out &&
894-
test_i18ngrep "CONFLICT (rename.*delete)" out &&
889+
# Instead of requiring the output to contain one combined line
890+
# CONFLICT (rename/add/delete)
891+
# or perhaps two lines:
892+
# CONFLICT (rename/add): new file collides with rename target
893+
# CONFLICT (rename/delete): rename source removed on other side
894+
# and instead of requiring "rename/add" instead of "add/add",
895+
# be flexible in the type of console output message(s) reported
896+
# for this particular case; we will be more stringent about the
897+
# contents of the index and working directory.
898+
test_i18ngrep "CONFLICT (.*/add)" out &&
899+
test_i18ngrep "CONFLICT (rename.*/delete)" out &&
895900
test_must_be_empty err &&
896901
897902
git ls-files -s >file_count &&
898903
test_line_count = 2 file_count &&
899904
git ls-files -u >file_count &&
900905
test_line_count = 2 file_count &&
901906
git ls-files -o >file_count &&
902-
test_line_count = 2 file_count &&
907+
test_line_count = 3 file_count &&
903908
904909
git rev-parse >actual \
905910
:2:bar :3:bar &&
906911
git rev-parse >expect \
907912
B:bar A:bar &&
908913
909-
test_cmp file_is_missing foo &&
914+
test_path_is_missing foo &&
910915
# bar should have two-way merged contents of the different
911916
# versions of bar; check that content from both sides is
912917
# present.
@@ -954,11 +959,17 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
954959
git checkout A^0 &&
955960
test_must_fail git merge -s recursive B^0 >out 2>err &&
956961
957-
# Not sure whether the output should contain just one
958-
# "CONFLICT (rename/rename/delete/delete)" line, or if it
959-
# should break it into three: "CONFLICT (rename/rename)" and
960-
# two "CONFLICT (rename/delete)" lines; allow for either.
961-
test_i18ngrep "CONFLICT (rename/rename)" out &&
962+
# Instead of requiring the output to contain one combined line
963+
# CONFLICT (rename/rename/delete/delete)
964+
# or perhaps two lines:
965+
# CONFLICT (rename/rename): ...
966+
# CONFLICT (rename/delete): info about pair 1
967+
# CONFLICT (rename/delete): info about pair 2
968+
# and instead of requiring "rename/rename" instead of "add/add",
969+
# be flexible in the type of console output message(s) reported
970+
# for this particular case; we will be more stringent about the
971+
# contents of the index and working directory.
972+
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
962973
test_i18ngrep "CONFLICT (rename.*delete)" out &&
963974
test_must_be_empty err &&
964975
@@ -967,15 +978,15 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' '
967978
git ls-files -u >file_count &&
968979
test_line_count = 2 file_count &&
969980
git ls-files -o >file_count &&
970-
test_line_count = 2 file_count &&
981+
test_line_count = 3 file_count &&
971982
972983
git rev-parse >actual \
973984
:2:baz :3:baz &&
974985
git rev-parse >expect \
975986
O:foo O:bar &&
976987
977-
test_cmp file_is_missing foo &&
978-
test_cmp file_is_missing bar &&
988+
test_path_is_missing foo &&
989+
test_path_is_missing bar &&
979990
# baz should have two-way merged contents of the original
980991
# contents of foo and bar; check that content from both sides
981992
# is present.
@@ -1042,25 +1053,25 @@ test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename
10421053
test_must_be_empty err &&
10431054
10441055
git ls-files -s >file_count &&
1045-
test_line_count = 6 file_count &&
1056+
test_line_count = 9 file_count &&
10461057
git ls-files -u >file_count &&
1047-
test_line_count = 6 file_count &&
1058+
test_line_count = 9 file_count &&
10481059
git ls-files -o >file_count &&
10491060
test_line_count = 3 file_count &&
10501061
10511062
test_seq 10 20 >merged-one &&
10521063
test_seq 51 60 >merged-five &&
10531064
# Determine what the merge of three would give us.
1054-
test_seq 30 40 >three-side-A &&
1065+
test_seq 31 39 >three-base &&
1066+
test_seq 31 40 >three-side-A &&
10551067
test_seq 31 39 >three-side-B &&
1056-
echo forty >three-side-B &&
1057-
>empty &&
1068+
echo forty >>three-side-B &&
10581069
test_must_fail git merge-file \
1059-
-L "HEAD" \
1070+
-L "HEAD:four" \
10601071
-L "" \
1061-
-L "B^0" \
1062-
three-side-A empty three-side-B &&
1063-
sed -e "s/^\([<=>]\)/\1\1\1/" three-side-A >merged-three &&
1072+
-L "B^0:two" \
1073+
three-side-A three-base three-side-B &&
1074+
sed -e "s/^\([<=>]\)/\1\1/" three-side-A >merged-three &&
10641075
10651076
# Verify the index is as expected
10661077
git rev-parse >actual \
@@ -1075,6 +1086,7 @@ test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename
10751086
10761087
git cat-file -p :2:two >expect &&
10771088
git cat-file -p :3:two >other &&
1089+
>empty &&
10781090
test_must_fail git merge-file \
10791091
-L "HEAD" -L "" -L "B^0" \
10801092
expect empty other &&

t/t6043-merge-rename-directories.sh renamed to t/t6423-merge-rename-directories.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ test_expect_success '1d: Directory renames cause a rename/rename(2to1) conflict'
275275
git checkout A^0 &&
276276
277277
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
278-
test_i18ngrep "CONFLICT (rename/rename)" out &&
278+
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
279279
280280
git ls-files -s >out &&
281281
test_line_count = 8 out &&
@@ -1686,7 +1686,7 @@ test_expect_success '7b: rename/rename(2to1), but only due to transitive rename'
16861686
git checkout A^0 &&
16871687
16881688
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
1689-
test_i18ngrep "CONFLICT (rename/rename)" out &&
1689+
test_i18ngrep "CONFLICT (\(.*\)/\1)" out &&
16901690
16911691
git ls-files -s >out &&
16921692
test_line_count = 4 out &&
@@ -2260,24 +2260,23 @@ test_expect_success '8d: rename/delete...or not?' '
22602260
# Commit B: w/{b,c}, z/d
22612261
#
22622262
# Possible Resolutions:
2263-
# w/o dir-rename detection: z/d, CONFLICT(z/b -> y/b vs. w/b),
2264-
# CONFLICT(z/c -> y/c vs. w/c)
2265-
# Currently expected: y/d, CONFLICT(z/b -> y/b vs. w/b),
2266-
# CONFLICT(z/c -> y/c vs. w/c)
2267-
# Optimal: ??
2263+
# if z not considered renamed: z/d, CONFLICT(z/b -> y/b vs. w/b),
2264+
# CONFLICT(z/c -> y/c vs. w/c)
2265+
# if z->y rename considered: y/d, CONFLICT(z/b -> y/b vs. w/b),
2266+
# CONFLICT(z/c -> y/c vs. w/c)
2267+
# Optimal: ??
22682268
#
22692269
# Notes: In commit A, directory z got renamed to y. In commit B, directory z
22702270
# did NOT get renamed; the directory is still present; instead it is
22712271
# considered to have just renamed a subset of paths in directory z
2272-
# elsewhere. Therefore, the directory rename done in commit A to z/
2273-
# applies to z/d and maps it to y/d.
2272+
# elsewhere. However, this is much like testcase 6b (where commit B
2273+
# moves all the original paths out of z/ but opted to keep d
2274+
# within z/). This makes it hard to judge where d should end up.
22742275
#
22752276
# It's possible that users would get confused about this, but what
2276-
# should we do instead? Silently leaving at z/d seems just as bad or
2277-
# maybe even worse. Perhaps we could print a big warning about z/d
2278-
# and how we're moving to y/d in this case, but when I started thinking
2279-
# about the ramifications of doing that, I didn't know how to rule out
2280-
# that opening other weird edge and corner cases so I just punted.
2277+
# should we do instead? It's not at all clear to me whether z/d or
2278+
# y/d or something else is a better resolution here, and other cases
2279+
# start getting really tricky, so I just picked one.
22812280

22822281
test_setup_8e () {
22832282
test_create_repo 8e &&
@@ -2844,6 +2843,14 @@ test_expect_success '9f: Renamed directory that only contained immediate subdirs
28442843
# Commit A: priority/{alpha,bravo}/$more_files
28452844
# Commit B: goal/{a,b}/$more_files, goal/c
28462845
# Expected: priority/{alpha,bravo}/$more_files, priority/c
2846+
# We currently fail this test because the directory renames we detect are
2847+
# goal/a/ -> priority/alpha/
2848+
# goal/b/ -> priority/bravo/
2849+
# We do not detect
2850+
# goal/ -> priority/
2851+
# because of no files found within goal/, and the fact that "a" != "alpha"
2852+
# and "b" != "bravo". But I'm not sure it's really a failure given that
2853+
# viewpoint...
28472854

28482855
test_setup_9g () {
28492856
test_create_repo 9g &&
@@ -2880,6 +2887,7 @@ test_setup_9g () {
28802887
}
28812888

28822889
test_expect_failure '9g: Renamed directory that only contained immediate subdirs, immediate subdirs renamed' '
2890+
test_setup_9g &&
28832891
(
28842892
cd 9g &&
28852893
@@ -3362,6 +3370,7 @@ test_setup_10e () {
33623370
}
33633371

33643372
test_expect_failure '10e: Does git complain about untracked file that is not really in the way?' '
3373+
test_setup_10e &&
33653374
(
33663375
cd 10e &&
33673376
@@ -4403,7 +4412,7 @@ test_expect_success '13b(info): messages for transitive rename with conflicted c
44034412
# Commit O: z/{b,c}, x/{d,e}
44044413
# Commit A: y/{b,c,d}, x/e
44054414
# Commit B: z/{b,c,d}, x/e
4406-
# Expected: y/{b,c,d}, with info or conflict messages for d (
4415+
# Expected: y/{b,c,d}, x/e, with info or conflict messages for d
44074416
# A: renamed x/d -> z/d; B: renamed z/ -> y/ AND renamed x/d to y/d
44084417
# One could argue A had partial knowledge of what was done with
44094418
# d and B had full knowledge, but that's a slippery slope as

t/t6045-merge-rename-delete.sh renamed to t/t6425-merge-rename-delete.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ test_expect_success 'rename/delete' '
1717
git commit -m "delete" &&
1818
1919
test_must_fail git merge --strategy=recursive rename >output &&
20-
test_i18ngrep "CONFLICT (rename/delete): A deleted in HEAD and renamed to B in rename. Version rename of B left in tree." output
20+
test_i18ngrep "CONFLICT (rename/delete): A.* renamed .*to B.* in rename" output &&
21+
test_i18ngrep "CONFLICT (rename/delete): A.*deleted in HEAD." output
2122
'
2223

2324
test_done

t/t6046-merge-skip-unneeded-updates.sh renamed to t/t6426-merge-skip-unneeded-updates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ test_expect_success '2c: Modify b & add c VS rename b->c' '
374374
export GIT_MERGE_VERBOSITY &&
375375
test_must_fail git merge -s recursive B^0 >out 2>err &&
376376
377-
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
377+
test_i18ngrep "CONFLICT (.*/add):" out &&
378378
test_must_be_empty err &&
379379
380380
# Make sure c WAS updated
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)