Skip to content

Commit

Permalink
reset: expand test coverage in sparse checkout
Browse files Browse the repository at this point in the history
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 <vdye@github.com>
  • Loading branch information
vdye authored and ldennington committed Jan 12, 2022
1 parent 4dd5e6c commit 85540db
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions t/t1092-sparse-checkout-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,87 @@ test_expect_success 'checkout and mixed reset file tracking [sparse]' '
test_path_exists full-checkout/folder1
'

test_expect_success 'checkout and reset (merge)' '
init_repos &&
write_script edit-contents <<-\EOF &&
echo text >>$1
EOF
test_all_match git checkout -b reset-test update-deep &&
run_on_all ../edit-contents a &&
test_all_match git reset --merge deepest &&
test_all_match git status --porcelain=v2 &&
test_all_match git reset --hard update-deep &&
run_on_all ../edit-contents deep/a &&
test_all_match test_must_fail git reset --merge deepest
'

test_expect_success 'checkout and reset (keep)' '
init_repos &&
write_script edit-contents <<-\EOF &&
echo text >>$1
EOF
test_all_match git checkout -b reset-test update-deep &&
run_on_all ../edit-contents a &&
test_all_match git reset --keep deepest &&
test_all_match git status --porcelain=v2 &&
test_all_match git reset --hard update-deep &&
run_on_all ../edit-contents deep/a &&
test_all_match test_must_fail git reset --keep deepest
'

test_expect_success 'reset with pathspecs inside sparse definition' '
init_repos &&
write_script edit-contents <<-\EOF &&
echo text >>$1
EOF
test_all_match git checkout -b reset-test update-deep &&
run_on_all ../edit-contents deep/a &&
test_all_match git reset base -- deep/a &&
test_all_match git status --porcelain=v2 &&
test_all_match git reset base -- nonexistent-file &&
test_all_match git status --porcelain=v2 &&
test_all_match git reset deepest -- deep &&
test_all_match git status --porcelain=v2
'

test_expect_success 'reset with sparse directory pathspec outside definition' '
init_repos &&
test_all_match git checkout -b reset-test update-deep &&
test_all_match git reset --hard update-folder1 &&
test_all_match git reset base -- folder1 &&
test_all_match git status --porcelain=v2
'

test_expect_success 'reset with file pathspec outside sparse definition' '
init_repos &&
test_all_match git checkout -b reset-test update-deep &&
test_all_match git reset --hard update-folder1 &&
test_all_match git reset base -- folder1/a &&
test_all_match git status --porcelain=v2
'

test_expect_success 'reset with wildcard pathspec' '
init_repos &&
test_all_match git checkout -b reset-test update-deep &&
test_all_match git reset --hard update-folder1 &&
test_all_match git reset base -- \*/a &&
test_all_match git status --porcelain=v2
'

test_expect_success 'merge, cherry-pick, and rebase' '
init_repos &&
Expand Down

0 comments on commit 85540db

Please sign in to comment.