@@ -1911,6 +1911,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
19111911 ensure_not_expanded sparse-checkout set
19121912'
19131913
1914+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1915+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1916+ # applying a stash of untracked files. As a result, the test reports that it
1917+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1918+ # performance implications of expanding the full repository index.
1919+ test_expect_success ' sparse index is not expanded: stash -u' '
1920+ init_repos &&
1921+
1922+ mkdir -p sparse-index/folder1 &&
1923+ echo >>sparse-index/README.md &&
1924+ echo >>sparse-index/a &&
1925+ echo >>sparse-index/folder1/new &&
1926+
1927+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1928+ git -C sparse-index stash -u &&
1929+ test_region index ensure_full_index trace2.txt &&
1930+
1931+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1932+ git -C sparse-index stash pop &&
1933+ test_region index ensure_full_index trace2.txt
1934+ '
1935+
1936+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1937+ # checkout definition are successfully stashed and unstashed.
1938+ test_expect_success ' stash -u outside sparse checkout definition' '
1939+ init_repos &&
1940+
1941+ write_script edit-contents <<-\EOF &&
1942+ echo text >>$1
1943+ EOF
1944+
1945+ run_on_sparse mkdir -p folder1 &&
1946+ run_on_all ../edit-contents folder1/new &&
1947+ test_all_match git stash -u &&
1948+ test_all_match git status --porcelain=v2 &&
1949+
1950+ test_all_match git stash pop -q &&
1951+ test_all_match git status --porcelain=v2
1952+ '
1953+
19141954# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
19151955# in this scenario, but it shouldn't.
19161956test_expect_success ' reset mixed and checkout orphan' '
0 commit comments