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