@@ -1820,6 +1820,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
1820
1820
ensure_not_expanded sparse-checkout set
1821
1821
'
1822
1822
1823
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1824
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1825
+ # applying a stash of untracked files. As a result, the test reports that it
1826
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1827
+ # performance implications of expanding the full repository index.
1828
+ test_expect_success ' sparse index is not expanded: stash -u' '
1829
+ init_repos &&
1830
+
1831
+ mkdir -p sparse-index/folder1 &&
1832
+ echo >>sparse-index/README.md &&
1833
+ echo >>sparse-index/a &&
1834
+ echo >>sparse-index/folder1/new &&
1835
+
1836
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1837
+ git -C sparse-index stash -u &&
1838
+ test_region index ensure_full_index trace2.txt &&
1839
+
1840
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1841
+ git -C sparse-index stash pop &&
1842
+ test_region index ensure_full_index trace2.txt
1843
+ '
1844
+
1845
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1846
+ # checkout definition are successfully stashed and unstashed.
1847
+ test_expect_success ' stash -u outside sparse checkout definition' '
1848
+ init_repos &&
1849
+
1850
+ write_script edit-contents <<-\EOF &&
1851
+ echo text >>$1
1852
+ EOF
1853
+
1854
+ run_on_sparse mkdir -p folder1 &&
1855
+ run_on_all ../edit-contents folder1/new &&
1856
+ test_all_match git stash -u &&
1857
+ test_all_match git status --porcelain=v2 &&
1858
+
1859
+ test_all_match git stash pop -q &&
1860
+ test_all_match git status --porcelain=v2
1861
+ '
1862
+
1823
1863
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1824
1864
# in this scenario, but it shouldn't.
1825
1865
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments