Skip to content

Commit e0fddaa

Browse files
committed
reset: add test demonstrating mixed reset outside sparse checkout
Mixed reset in a sparse checkout (cone mode or otherwise) will, if a file outside of the sparse definition has differences between the working tree and target, write the file to the local working copy of the repository. Since this behavior conflicts with the typical expectations of a strict checkout definition/cone, a test is added demonstrating (and explaining) it. Signed-off-by: Victoria Dye <[email protected]>
1 parent 4bcd533 commit e0fddaa

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,32 @@ test_expect_success 'checkout and reset (mixed) [sparse]' '
480480
test_sparse_match git reset update-folder2
481481
'
482482

483+
# NEEDSWORK: with mixed reset, files with differences between HEAD and <commit>
484+
# will be added to the work tree even if outside the sparse checkout
485+
# definition, and even if the file is modified to a state of having no local
486+
# changes. The file is "re-ignored" if a hard reset is executed. We may want to
487+
# change this behavior in the future and enforce that files are not written
488+
# outside of the sparse checkout definition.
489+
test_expect_success 'checkout and mixed reset file tracking [sparse]' '
490+
init_repos &&
491+
492+
test_all_match git checkout -b reset-test update-deep &&
493+
test_all_match git reset update-folder1 &&
494+
test_all_match git reset update-deep &&
495+
496+
# At this point, there are no changes in the working tree. However,
497+
# folder1/a now exists locally (even though it is outside of the sparse
498+
# paths).
499+
run_on_sparse test_path_exists folder1 &&
500+
501+
run_on_all rm folder1/a &&
502+
test_all_match git status --porcelain=v2 &&
503+
504+
test_all_match git reset --hard update-deep &&
505+
run_on_sparse test_path_is_missing folder1 &&
506+
test_path_exists full-checkout/folder1
507+
'
508+
483509
test_expect_success 'merge, cherry-pick, and rebase' '
484510
init_repos &&
485511

0 commit comments

Comments
 (0)