Skip to content

Commit 5cb1841

Browse files
vdyeldennington
authored andcommitted
Merge pull request microsoft#417 from vdye/sparse-index/git-reset
Sparse index: `git reset`
2 parents 5aeea55 + 7e1948b commit 5cb1841

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,113 @@ test_expect_success 'reset with wildcard pathspec' '
630630
test_all_match git ls-files -s -- folder1
631631
'
632632

633+
# NEEDSWORK: with mixed reset, files with differences between HEAD and <commit>
634+
# will be added to the work tree even if outside the sparse checkout
635+
# definition, and even if the file is modified to a state of having no local
636+
# changes. The file is "re-ignored" if a hard reset is executed. We may want to
637+
# change this behavior in the future and enforce that files are not written
638+
# outside of the sparse checkout definition.
639+
test_expect_success 'checkout and mixed reset file tracking [sparse]' '
640+
init_repos &&
641+
642+
test_all_match git checkout -b reset-test update-deep &&
643+
test_all_match git reset update-folder1 &&
644+
test_all_match git reset update-deep &&
645+
646+
# At this point, there are no changes in the working tree. However,
647+
# folder1/a now exists locally (even though it is outside of the sparse
648+
# paths).
649+
run_on_sparse test_path_exists folder1 &&
650+
651+
run_on_all rm folder1/a &&
652+
test_all_match git status --porcelain=v2 &&
653+
654+
test_all_match git reset --hard update-deep &&
655+
run_on_sparse test_path_is_missing folder1 &&
656+
test_path_exists full-checkout/folder1
657+
'
658+
659+
test_expect_success 'checkout and reset (merge)' '
660+
init_repos &&
661+
662+
write_script edit-contents <<-\EOF &&
663+
echo text >>$1
664+
EOF
665+
666+
test_all_match git checkout -b reset-test update-deep &&
667+
run_on_all ../edit-contents a &&
668+
test_all_match git reset --merge deepest &&
669+
test_all_match git status --porcelain=v2 &&
670+
671+
test_all_match git reset --hard update-deep &&
672+
run_on_all ../edit-contents deep/a &&
673+
test_all_match test_must_fail git reset --merge deepest
674+
'
675+
676+
test_expect_success 'checkout and reset (keep)' '
677+
init_repos &&
678+
679+
write_script edit-contents <<-\EOF &&
680+
echo text >>$1
681+
EOF
682+
683+
test_all_match git checkout -b reset-test update-deep &&
684+
run_on_all ../edit-contents a &&
685+
test_all_match git reset --keep deepest &&
686+
test_all_match git status --porcelain=v2 &&
687+
688+
test_all_match git reset --hard update-deep &&
689+
run_on_all ../edit-contents deep/a &&
690+
test_all_match test_must_fail git reset --keep deepest
691+
'
692+
693+
test_expect_success 'reset with pathspecs inside sparse definition' '
694+
init_repos &&
695+
696+
write_script edit-contents <<-\EOF &&
697+
echo text >>$1
698+
EOF
699+
700+
test_all_match git checkout -b reset-test update-deep &&
701+
run_on_all ../edit-contents deep/a &&
702+
703+
test_all_match git reset base -- deep/a &&
704+
test_all_match git status --porcelain=v2 &&
705+
706+
test_all_match git reset base -- nonexistent-file &&
707+
test_all_match git status --porcelain=v2 &&
708+
709+
test_all_match git reset deepest -- deep &&
710+
test_all_match git status --porcelain=v2
711+
'
712+
713+
test_expect_success 'reset with sparse directory pathspec outside definition' '
714+
init_repos &&
715+
716+
test_all_match git checkout -b reset-test update-deep &&
717+
test_all_match git reset --hard update-folder1 &&
718+
test_all_match git reset base -- folder1 &&
719+
test_all_match git status --porcelain=v2
720+
'
721+
722+
test_expect_success 'reset with file pathspec outside sparse definition' '
723+
init_repos &&
724+
725+
test_all_match git checkout -b reset-test update-deep &&
726+
test_all_match git reset --hard update-folder1 &&
727+
test_all_match git reset base -- folder1/a &&
728+
test_all_match git status --porcelain=v2
729+
'
730+
731+
test_expect_success 'reset with wildcard pathspec' '
732+
init_repos &&
733+
734+
test_all_match git checkout -b reset-test update-deep &&
735+
test_all_match git reset --hard update-folder1 &&
736+
test_all_match git reset base -- \*/a &&
737+
test_all_match git status --porcelain=v2
738+
'
739+
633740
test_expect_success 'merge, cherry-pick, and rebase' '
634741
init_repos &&
635742

0 commit comments

Comments
 (0)