stash: expand sparse-checkout compatibility testing

Add tests verifying expected 'git stash' behavior in
't1092-sparse-checkout-compatibility'. These cases establish the expected
behavior of 'git stash' in a sparse-checkout and verify consistency both
with and without a sparse index. Although no sparse index compatibility has
been integrated into 'git stash' yet, the tests are all 'expect_success' -
we don't want the cone-mode sparse-checkout behavior to change depending on
whether it is using a sparse index or not. Therefore, we expect these tests
to continue passing once sparse index is integrated with 'git stash'.

Additionally, add performance test cases for 'git stash' both with and
without untracked files. Note that, unlike the other tests in
'p2000-sparse-operations.sh', the tests added for 'stash' are combination
operations. This is done to ensure the stash/unstash is not blocked by the
modification of '$SPARSE_CONE/a' performed as part of 'test_perf_on_all'.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Victoria Dye 2022-05-10 23:32:27 +00:00 committed by Junio C Hamano
parent 6cd33dceed
commit eae937059b
2 changed files with 51 additions and 0 deletions

View file

@ -106,6 +106,8 @@ test_perf_on_all () {
}
test_perf_on_all git status
test_perf_on_all 'git stash && git stash pop'
test_perf_on_all 'echo >>new && git stash -u && git stash pop'
test_perf_on_all git add -A
test_perf_on_all git add .
test_perf_on_all git commit -a -m A

View file

@ -1034,6 +1034,55 @@ test_expect_success 'cherry-pick with conflicts' '
test_all_match test_must_fail git cherry-pick to-cherry-pick
'
test_expect_success 'stash' '
init_repos &&
write_script edit-contents <<-\EOF &&
echo text >>$1
EOF
# Stash a sparse directory (folder1)
test_all_match git checkout -b test-branch rename-base &&
test_all_match git reset --soft rename-out-to-out &&
test_all_match git stash &&
test_all_match git status --porcelain=v2 &&
# Apply the sparse directory stash without reinstating the index
test_all_match git stash apply -q &&
test_all_match git status --porcelain=v2 &&
# Reset to state where stash can be applied
test_sparse_match git sparse-checkout reapply &&
test_all_match git reset --hard rename-out-to-out &&
# Apply the sparse directory stash *with* reinstating the index
test_all_match git stash apply --index -q &&
test_all_match git status --porcelain=v2 &&
# Reset to state where we will get a conflict applying the stash
test_sparse_match git sparse-checkout reapply &&
test_all_match git reset --hard update-folder1 &&
# Apply the sparse directory stash with conflicts
test_all_match test_must_fail git stash apply --index -q &&
test_all_match test_must_fail git stash apply -q &&
test_all_match git status --porcelain=v2 &&
# Reset to base branch
test_sparse_match git sparse-checkout reapply &&
test_all_match git reset --hard base &&
# Stash & unstash an untracked file outside of the sparse checkout
# definition.
run_on_sparse mkdir -p folder1 &&
run_on_all ../edit-contents folder1/new &&
test_all_match git stash -u &&
test_all_match git status --porcelain=v2 &&
test_all_match git stash pop -q &&
test_all_match git status --porcelain=v2
'
test_expect_success 'checkout-index inside sparse definition' '
init_repos &&