@@ -114,6 +114,16 @@ test_expect_success 'setup' '
114
114
git add . &&
115
115
git commit -m "file to dir" &&
116
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
+
117
127
git checkout -b deepest base &&
118
128
echo "updated deepest" >deep/deeper1/deepest/a &&
119
129
git commit -a -m "update deepest" &&
@@ -312,9 +322,6 @@ test_expect_success 'commit including unstaged changes' '
312
322
test_expect_success ' status/add: outside sparse cone' '
313
323
init_repos &&
314
324
315
- # adding a "missing" file outside the cone should fail
316
- test_sparse_match test_must_fail git add folder1/a &&
317
-
318
325
# folder1 is at HEAD, but outside the sparse cone
319
326
run_on_sparse mkdir folder1 &&
320
327
cp initial-repo/folder1/a sparse-checkout/folder1/a &&
@@ -330,21 +337,23 @@ test_expect_success 'status/add: outside sparse cone' '
330
337
331
338
test_sparse_match git status --porcelain=v2 &&
332
339
333
- # This "git add folder1/a" fails with a warning
334
- # in the sparse repos, differing from the full
335
- # repo. This is intentional.
340
+ # Adding the path outside of the sparse-checkout cone should fail.
336
341
test_sparse_match test_must_fail git add folder1/a &&
337
342
test_sparse_match test_must_fail git add --refresh folder1/a &&
338
- test_all_match git status --porcelain=v2 &&
343
+
344
+ # NEEDSWORK: Adding a newly-tracked file outside the cone succeeds
345
+ test_sparse_match git add folder1/new &&
339
346
340
347
test_all_match git add . &&
341
348
test_all_match git status --porcelain=v2 &&
342
349
test_all_match git commit -m folder1/new &&
350
+ test_all_match git rev-parse HEAD^{tree} &&
343
351
344
352
run_on_all ../edit-contents folder1/newer &&
345
353
test_all_match git add folder1/ &&
346
354
test_all_match git status --porcelain=v2 &&
347
- test_all_match git commit -m folder1/newer
355
+ test_all_match git commit -m folder1/newer &&
356
+ test_all_match git rev-parse HEAD^{tree}
348
357
'
349
358
350
359
test_expect_success ' checkout and reset --hard' '
@@ -482,6 +491,39 @@ test_expect_success 'merge' '
482
491
test_all_match git rev-parse HEAD^{tree}
483
492
'
484
493
494
+ # NEEDSWORK: This test is documenting current behavior, but that
495
+ # behavior can be confusing to users so there is desire to change it.
496
+ # Right now, users might be using this flow to work through conflicts,
497
+ # so any solution should present advice to users who try this sequence
498
+ # of commands to follow whatever new method we create.
499
+ test_expect_success ' merge with conflict outside cone' '
500
+ init_repos &&
501
+
502
+ test_all_match git checkout -b merge-tip merge-left &&
503
+ test_all_match git status --porcelain=v2 &&
504
+ test_all_match test_must_fail git merge -m merge merge-right &&
505
+ test_all_match git status --porcelain=v2 &&
506
+
507
+ # Resolve the conflict in different ways:
508
+ # 1. Revert to the base
509
+ test_all_match git checkout base -- deep/deeper2/a &&
510
+ test_all_match git status --porcelain=v2 &&
511
+
512
+ # 2. Add the file with conflict markers
513
+ test_all_match git add folder1/a &&
514
+ test_all_match git status --porcelain=v2 &&
515
+
516
+ # 3. Rename the file to another sparse filename and
517
+ # accept conflict markers as resolved content.
518
+ run_on_all mv folder2/a folder2/z &&
519
+ test_all_match git add folder2 &&
520
+ test_all_match git status --porcelain=v2 &&
521
+
522
+ test_all_match git merge --continue &&
523
+ test_all_match git status --porcelain=v2 &&
524
+ test_all_match git rev-parse HEAD^{tree}
525
+ '
526
+
485
527
test_expect_success ' merge with outside renames' '
486
528
init_repos &&
487
529
@@ -598,7 +640,14 @@ test_expect_success 'sparse-index is not expanded' '
598
640
git -C sparse-index reset --hard &&
599
641
ensure_not_expanded checkout rename-out-to-out -- deep/deeper1 &&
600
642
git -C sparse-index reset --hard &&
601
- ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1
643
+ ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1 &&
644
+
645
+ echo >>sparse-index/README.md &&
646
+ ensure_not_expanded add -A &&
647
+ echo >>sparse-index/extra.txt &&
648
+ ensure_not_expanded add extra.txt &&
649
+ echo >>sparse-index/untracked.txt &&
650
+ ensure_not_expanded add .
602
651
'
603
652
604
653
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
0 commit comments