Skip to content

Commit 4dd5e6c

Browse files
vdyeldennington
authored andcommitted
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 <vdye@github.com>
1 parent aca9337 commit 4dd5e6c

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
@@ -629,6 +629,32 @@ test_expect_success 'reset with wildcard pathspec' '
629629
test_all_match git ls-files -s -- folder1
630630
'
631631

632+
# NEEDSWORK: with mixed reset, files with differences between HEAD and <commit>
633+
# will be added to the work tree even if outside the sparse checkout
634+
# definition, and even if the file is modified to a state of having no local
635+
# changes. The file is "re-ignored" if a hard reset is executed. We may want to
636+
# change this behavior in the future and enforce that files are not written
637+
# outside of the sparse checkout definition.
638+
test_expect_success 'checkout and mixed reset file tracking [sparse]' '
639+
init_repos &&
640+
641+
test_all_match git checkout -b reset-test update-deep &&
642+
test_all_match git reset update-folder1 &&
643+
test_all_match git reset update-deep &&
644+
645+
# At this point, there are no changes in the working tree. However,
646+
# folder1/a now exists locally (even though it is outside of the sparse
647+
# paths).
648+
run_on_sparse test_path_exists folder1 &&
649+
650+
run_on_all rm folder1/a &&
651+
test_all_match git status --porcelain=v2 &&
652+
653+
test_all_match git reset --hard update-deep &&
654+
run_on_sparse test_path_is_missing folder1 &&
655+
test_path_exists full-checkout/folder1
656+
'
657+
632658
test_expect_success 'merge, cherry-pick, and rebase' '
633659
init_repos &&
634660

0 commit comments

Comments
 (0)