@@ -1781,6 +1781,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
17811781 ensure_not_expanded sparse-checkout set
17821782'
17831783
1784+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1785+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1786+ # applying a stash of untracked files. As a result, the test reports that it
1787+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1788+ # performance implications of expanding the full repository index.
1789+ test_expect_success ' sparse index is not expanded: stash -u' '
1790+ init_repos &&
1791+
1792+ mkdir -p sparse-index/folder1 &&
1793+ echo >>sparse-index/README.md &&
1794+ echo >>sparse-index/a &&
1795+ echo >>sparse-index/folder1/new &&
1796+
1797+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1798+ git -C sparse-index stash -u &&
1799+ test_region index ensure_full_index trace2.txt &&
1800+
1801+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1802+ git -C sparse-index stash pop &&
1803+ test_region index ensure_full_index trace2.txt
1804+ '
1805+
1806+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1807+ # checkout definition are successfully stashed and unstashed.
1808+ test_expect_success ' stash -u outside sparse checkout definition' '
1809+ init_repos &&
1810+
1811+ write_script edit-contents <<-\EOF &&
1812+ echo text >>$1
1813+ EOF
1814+
1815+ run_on_sparse mkdir -p folder1 &&
1816+ run_on_all ../edit-contents folder1/new &&
1817+ test_all_match git stash -u &&
1818+ test_all_match git status --porcelain=v2 &&
1819+
1820+ test_all_match git stash pop -q &&
1821+ test_all_match git status --porcelain=v2
1822+ '
1823+
17841824# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
17851825# in this scenario, but it shouldn't.
17861826test_expect_success ' reset mixed and checkout orphan' '
0 commit comments