Skip to content

Commit e934f4f

Browse files
committed
reset: expand test coverage in sparse checkout
Add tests for `--merge` and `--keep` modes, as well as (mixed) reset with pathspecs both inside and outside of the sparse checkout definition. Signed-off-by: Victoria Dye <[email protected]>
1 parent e0fddaa commit e934f4f

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,87 @@ test_expect_success 'checkout and mixed reset file tracking [sparse]' '
506506
test_path_exists full-checkout/folder1
507507
'
508508

509+
test_expect_success 'checkout and reset (merge)' '
510+
init_repos &&
511+
512+
write_script edit-contents <<-\EOF &&
513+
echo text >>$1
514+
EOF
515+
516+
test_all_match git checkout -b reset-test update-deep &&
517+
run_on_all ../edit-contents a &&
518+
test_all_match git reset --merge deepest &&
519+
test_all_match git status --porcelain=v2 &&
520+
521+
test_all_match git reset --hard update-deep &&
522+
run_on_all ../edit-contents deep/a &&
523+
test_all_match test_must_fail git reset --merge deepest
524+
'
525+
526+
test_expect_success 'checkout and reset (keep)' '
527+
init_repos &&
528+
529+
write_script edit-contents <<-\EOF &&
530+
echo text >>$1
531+
EOF
532+
533+
test_all_match git checkout -b reset-test update-deep &&
534+
run_on_all ../edit-contents a &&
535+
test_all_match git reset --keep deepest &&
536+
test_all_match git status --porcelain=v2 &&
537+
538+
test_all_match git reset --hard update-deep &&
539+
run_on_all ../edit-contents deep/a &&
540+
test_all_match test_must_fail git reset --keep deepest
541+
'
542+
543+
test_expect_success 'reset with pathspecs inside sparse definition' '
544+
init_repos &&
545+
546+
write_script edit-contents <<-\EOF &&
547+
echo text >>$1
548+
EOF
549+
550+
test_all_match git checkout -b reset-test update-deep &&
551+
run_on_all ../edit-contents deep/a &&
552+
553+
test_all_match git reset base -- deep/a &&
554+
test_all_match git status --porcelain=v2 &&
555+
556+
test_all_match git reset base -- nonexistent-file &&
557+
test_all_match git status --porcelain=v2 &&
558+
559+
test_all_match git reset deepest -- deep &&
560+
test_all_match git status --porcelain=v2
561+
'
562+
563+
test_expect_success 'reset with sparse directory pathspec outside definition' '
564+
init_repos &&
565+
566+
test_all_match git checkout -b reset-test update-deep &&
567+
test_all_match git reset --hard update-folder1 &&
568+
test_all_match git reset base -- folder1 &&
569+
test_all_match git status --porcelain=v2
570+
'
571+
572+
test_expect_success 'reset with file pathspec outside sparse definition' '
573+
init_repos &&
574+
575+
test_all_match git checkout -b reset-test update-deep &&
576+
test_all_match git reset --hard update-folder1 &&
577+
test_all_match git reset base -- folder1/a &&
578+
test_all_match git status --porcelain=v2
579+
'
580+
581+
test_expect_success 'reset with wildcard pathspec' '
582+
init_repos &&
583+
584+
test_all_match git checkout -b reset-test update-deep &&
585+
test_all_match git reset --hard update-folder1 &&
586+
test_all_match git reset base -- */a &&
587+
test_all_match git status --porcelain=v2
588+
'
589+
509590
test_expect_success 'merge, cherry-pick, and rebase' '
510591
init_repos &&
511592

0 commit comments

Comments
 (0)