Skip to content

Commit 5e96df4

Browse files
committed
t1092: test merge conflicts outside cone
Conflicts can occur outside of the sparse-checkout definition, and in that case users might try to resolve the conflicts in several ways. Document a few of these ways in a test. Make it clear that this behavior is not necessarily the optimal flow, since users can become confused when Git deletes these files from the worktree in later commands. Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent 71e3015 commit 5e96df4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ test_expect_success 'setup' '
114114
git add . &&
115115
git commit -m "file to dir" &&
116116
117+
for side in left right
118+
do
119+
git checkout -b merge-$side base &&
120+
echo $side >>deep/deeper2/a &&
121+
echo $side >>folder1/a &&
122+
echo $side >>folder2/a &&
123+
git add . &&
124+
git commit -m "$side" || return 1
125+
done &&
126+
117127
git checkout -b deepest base &&
118128
echo "updated deepest" >deep/deeper1/deepest/a &&
119129
git commit -a -m "update deepest" &&
@@ -482,6 +492,39 @@ test_expect_success 'merge' '
482492
test_all_match git rev-parse HEAD^{tree}
483493
'
484494

495+
# NEEDSWORK: This test is documenting current behavior, but that
496+
# behavior can be confusing to users so there is desire to change it.
497+
# Right now, users might be using this flow to work through conflicts,
498+
# so any solution should present advice to users who try this sequence
499+
# of commands to follow whatever new method we create.
500+
test_expect_success 'merge with conflict outside cone' '
501+
init_repos &&
502+
503+
test_all_match git checkout -b merge-tip merge-left &&
504+
test_all_match git status --porcelain=v2 &&
505+
test_all_match test_must_fail git merge -m merge merge-right &&
506+
test_all_match git status --porcelain=v2 &&
507+
508+
# Resolve the conflict in different ways:
509+
# 1. Revert to the base
510+
test_all_match git checkout base -- deep/deeper2/a &&
511+
test_all_match git status --porcelain=v2 &&
512+
513+
# 2. Add the file with conflict markers
514+
test_all_match git add folder1/a &&
515+
test_all_match git status --porcelain=v2 &&
516+
517+
# 3. Rename the file to another sparse filename and
518+
# accept conflict markers as resolved content.
519+
run_on_all mv folder2/a folder2/z &&
520+
test_all_match git add folder2 &&
521+
test_all_match git status --porcelain=v2 &&
522+
523+
test_all_match git merge --continue &&
524+
test_all_match git status --porcelain=v2 &&
525+
test_all_match git rev-parse HEAD^{tree}
526+
'
527+
485528
test_expect_success 'merge with outside renames' '
486529
init_repos &&
487530

0 commit comments

Comments
 (0)