@@ -1123,23 +1123,42 @@ test_expect_success 'clean' '
11231123 test_all_match git commit -m "ignore bogus files" &&
11241124
11251125 run_on_sparse mkdir folder1 &&
1126+ run_on_all mkdir -p deep/untracked-deep &&
11261127 run_on_all touch folder1/bogus &&
1128+ run_on_all touch folder1/untracked &&
1129+ run_on_all touch deep/untracked-deep/bogus &&
1130+ run_on_all touch deep/untracked-deep/untracked &&
11271131
11281132 test_all_match git status --porcelain=v2 &&
11291133 test_all_match git clean -f &&
11301134 test_all_match git status --porcelain=v2 &&
11311135 test_sparse_match ls &&
11321136 test_sparse_match ls folder1 &&
1137+ run_on_all test_path_exists folder1/bogus &&
1138+ run_on_all test_path_is_missing folder1/untracked &&
1139+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1140+ run_on_all test_path_exists deep/untracked-deep/untracked &&
1141+
1142+ test_all_match git clean -fd &&
1143+ test_all_match git status --porcelain=v2 &&
1144+ test_sparse_match ls &&
1145+ test_sparse_match ls folder1 &&
1146+ run_on_all test_path_exists folder1/bogus &&
1147+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1148+ run_on_all test_path_is_missing deep/untracked-deep/untracked &&
11331149
11341150 test_all_match git clean -xf &&
11351151 test_all_match git status --porcelain=v2 &&
11361152 test_sparse_match ls &&
11371153 test_sparse_match ls folder1 &&
1154+ run_on_all test_path_is_missing folder1/bogus &&
1155+ run_on_all test_path_exists deep/untracked-deep/bogus &&
11381156
11391157 test_all_match git clean -xdf &&
11401158 test_all_match git status --porcelain=v2 &&
11411159 test_sparse_match ls &&
11421160 test_sparse_match ls folder1 &&
1161+ run_on_all test_path_is_missing deep/untracked-deep/bogus &&
11431162
11441163 test_sparse_match test_path_is_dir folder1
11451164'
@@ -1290,6 +1309,8 @@ test_expect_success 'sparse-index is not expanded' '
12901309 git -C sparse-index add README.md &&
12911310 ensure_not_expanded diff --staged &&
12921311
1312+ ensure_not_expanded clean -fd &&
1313+
12931314 ensure_not_expanded reset base -- deep/a &&
12941315 ensure_not_expanded reset base -- nonexistent-file &&
12951316 ensure_not_expanded reset deepest -- deep &&
@@ -1536,6 +1557,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
15361557 ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
15371558'
15381559
1560+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1561+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1562+ # applying a stash of untracked files. As a result, the test reports that it
1563+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1564+ # performance implications of expanding the full repository index.
1565+ test_expect_success ' sparse index is not expanded: stash -u' '
1566+ init_repos &&
1567+
1568+ mkdir -p sparse-index/folder1 &&
1569+ echo >>sparse-index/README.md &&
1570+ echo >>sparse-index/a &&
1571+ echo >>sparse-index/folder1/new &&
1572+
1573+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1574+ git -C sparse-index stash -u &&
1575+ test_region index ensure_full_index trace2.txt &&
1576+
1577+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1578+ git -C sparse-index stash pop &&
1579+ test_region index ensure_full_index trace2.txt
1580+ '
1581+
1582+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1583+ # checkout definition are successfully stashed and unstashed.
1584+ test_expect_success ' stash -u outside sparse checkout definition' '
1585+ init_repos &&
1586+
1587+ write_script edit-contents <<-\EOF &&
1588+ echo text >>$1
1589+ EOF
1590+
1591+ run_on_sparse mkdir -p folder1 &&
1592+ run_on_all ../edit-contents folder1/new &&
1593+ test_all_match git stash -u &&
1594+ test_all_match git status --porcelain=v2 &&
1595+
1596+ test_all_match git stash pop -q &&
1597+ test_all_match git status --porcelain=v2
1598+ '
1599+
15391600# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
15401601# in this scenario, but it shouldn't.
15411602test_expect_success ' reset mixed and checkout orphan' '
0 commit comments