@@ -655,6 +655,87 @@ test_expect_success 'checkout and mixed reset file tracking [sparse]' '
655655 test_path_exists full-checkout/folder1
656656'
657657
658+ test_expect_success ' checkout and reset (merge)' '
659+ init_repos &&
660+
661+ write_script edit-contents <<-\EOF &&
662+ echo text >>$1
663+ EOF
664+
665+ test_all_match git checkout -b reset-test update-deep &&
666+ run_on_all ../edit-contents a &&
667+ test_all_match git reset --merge deepest &&
668+ test_all_match git status --porcelain=v2 &&
669+
670+ test_all_match git reset --hard update-deep &&
671+ run_on_all ../edit-contents deep/a &&
672+ test_all_match test_must_fail git reset --merge deepest
673+ '
674+
675+ test_expect_success ' checkout and reset (keep)' '
676+ init_repos &&
677+
678+ write_script edit-contents <<-\EOF &&
679+ echo text >>$1
680+ EOF
681+
682+ test_all_match git checkout -b reset-test update-deep &&
683+ run_on_all ../edit-contents a &&
684+ test_all_match git reset --keep deepest &&
685+ test_all_match git status --porcelain=v2 &&
686+
687+ test_all_match git reset --hard update-deep &&
688+ run_on_all ../edit-contents deep/a &&
689+ test_all_match test_must_fail git reset --keep deepest
690+ '
691+
692+ test_expect_success ' reset with pathspecs inside sparse definition' '
693+ init_repos &&
694+
695+ write_script edit-contents <<-\EOF &&
696+ echo text >>$1
697+ EOF
698+
699+ test_all_match git checkout -b reset-test update-deep &&
700+ run_on_all ../edit-contents deep/a &&
701+
702+ test_all_match git reset base -- deep/a &&
703+ test_all_match git status --porcelain=v2 &&
704+
705+ test_all_match git reset base -- nonexistent-file &&
706+ test_all_match git status --porcelain=v2 &&
707+
708+ test_all_match git reset deepest -- deep &&
709+ test_all_match git status --porcelain=v2
710+ '
711+
712+ test_expect_success ' reset with sparse directory pathspec outside definition' '
713+ init_repos &&
714+
715+ test_all_match git checkout -b reset-test update-deep &&
716+ test_all_match git reset --hard update-folder1 &&
717+ test_all_match git reset base -- folder1 &&
718+ test_all_match git status --porcelain=v2
719+ '
720+
721+ test_expect_success ' reset with file pathspec outside sparse definition' '
722+ init_repos &&
723+
724+ test_all_match git checkout -b reset-test update-deep &&
725+ test_all_match git reset --hard update-folder1 &&
726+ test_all_match git reset base -- folder1/a &&
727+ test_all_match git status --porcelain=v2
728+ '
729+
730+ test_expect_success ' reset with wildcard pathspec' '
731+ init_repos &&
732+
733+ test_all_match git checkout -b reset-test update-deep &&
734+ test_all_match git reset --hard update-folder1 &&
735+ test_all_match git reset base -- \*/a &&
736+ test_all_match git status --porcelain=v2
737+ '
738+
658739test_expect_success ' merge, cherry-pick, and rebase' '
659740 init_repos &&
660741
0 commit comments