@@ -1593,6 +1593,46 @@ test_expect_success 'sparse index is not expanded: sparse-checkout' '
1593
1593
ensure_not_expanded sparse-checkout set
1594
1594
'
1595
1595
1596
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1597
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1598
+ # applying a stash of untracked files. As a result, the test reports that it
1599
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1600
+ # performance implications of expanding the full repository index.
1601
+ test_expect_success ' sparse index is not expanded: stash -u' '
1602
+ init_repos &&
1603
+
1604
+ mkdir -p sparse-index/folder1 &&
1605
+ echo >>sparse-index/README.md &&
1606
+ echo >>sparse-index/a &&
1607
+ echo >>sparse-index/folder1/new &&
1608
+
1609
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1610
+ git -C sparse-index stash -u &&
1611
+ test_region index ensure_full_index trace2.txt &&
1612
+
1613
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1614
+ git -C sparse-index stash pop &&
1615
+ test_region index ensure_full_index trace2.txt
1616
+ '
1617
+
1618
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1619
+ # checkout definition are successfully stashed and unstashed.
1620
+ test_expect_success ' stash -u outside sparse checkout definition' '
1621
+ init_repos &&
1622
+
1623
+ write_script edit-contents <<-\EOF &&
1624
+ echo text >>$1
1625
+ EOF
1626
+
1627
+ run_on_sparse mkdir -p folder1 &&
1628
+ run_on_all ../edit-contents folder1/new &&
1629
+ test_all_match git stash -u &&
1630
+ test_all_match git status --porcelain=v2 &&
1631
+
1632
+ test_all_match git stash pop -q &&
1633
+ test_all_match git status --porcelain=v2
1634
+ '
1635
+
1596
1636
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1597
1637
# in this scenario, but it shouldn't.
1598
1638
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments