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 <newren@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jul 29, 2021 at 14:52 UTC
83ad8ca596dd879d2907a240fb24a1603bb1decc
1 file changed
+43
t/t1092-sparse-checkout-compatibility.sh
+43
@@ -114,6 +114,16 @@ test_expect_success 'setup' '
114
git add . &&
115
git commit -m "file to dir" &&
116
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
+
127
git checkout -b deepest base &&
128
echo "updated deepest" >deep/deeper1/deepest/a &&
129
git commit -a -m "update deepest" &&
@@ -482,6 +492,39 @@ test_expect_success 'merge' '
492
test_all_match git rev-parse HEAD^{tree}
493
'
494
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
+
528
test_expect_success 'merge with outside renames' '
529
init_repos &&
530