@@ -1849,6 +1849,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
1849
1849
ensure_not_expanded sparse-checkout set
1850
1850
'
1851
1851
1852
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1853
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1854
+ # applying a stash of untracked files. As a result, the test reports that it
1855
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1856
+ # performance implications of expanding the full repository index.
1857
+ test_expect_success ' sparse index is not expanded: stash -u' '
1858
+ init_repos &&
1859
+
1860
+ mkdir -p sparse-index/folder1 &&
1861
+ echo >>sparse-index/README.md &&
1862
+ echo >>sparse-index/a &&
1863
+ echo >>sparse-index/folder1/new &&
1864
+
1865
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1866
+ git -C sparse-index stash -u &&
1867
+ test_region index ensure_full_index trace2.txt &&
1868
+
1869
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1870
+ git -C sparse-index stash pop &&
1871
+ test_region index ensure_full_index trace2.txt
1872
+ '
1873
+
1874
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1875
+ # checkout definition are successfully stashed and unstashed.
1876
+ test_expect_success ' stash -u outside sparse checkout definition' '
1877
+ init_repos &&
1878
+
1879
+ write_script edit-contents <<-\EOF &&
1880
+ echo text >>$1
1881
+ EOF
1882
+
1883
+ run_on_sparse mkdir -p folder1 &&
1884
+ run_on_all ../edit-contents folder1/new &&
1885
+ test_all_match git stash -u &&
1886
+ test_all_match git status --porcelain=v2 &&
1887
+
1888
+ test_all_match git stash pop -q &&
1889
+ test_all_match git status --porcelain=v2
1890
+ '
1891
+
1852
1892
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1853
1893
# in this scenario, but it shouldn't.
1854
1894
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments