@@ -1223,23 +1223,42 @@ test_expect_success 'clean' '
1223
1223
test_all_match git commit -m "ignore bogus files" &&
1224
1224
1225
1225
run_on_sparse mkdir folder1 &&
1226
+ run_on_all mkdir -p deep/untracked-deep &&
1226
1227
run_on_all touch folder1/bogus &&
1228
+ run_on_all touch folder1/untracked &&
1229
+ run_on_all touch deep/untracked-deep/bogus &&
1230
+ run_on_all touch deep/untracked-deep/untracked &&
1227
1231
1228
1232
test_all_match git status --porcelain=v2 &&
1229
1233
test_all_match git clean -f &&
1230
1234
test_all_match git status --porcelain=v2 &&
1231
1235
test_sparse_match ls &&
1232
1236
test_sparse_match ls folder1 &&
1237
+ run_on_all test_path_exists folder1/bogus &&
1238
+ run_on_all test_path_is_missing folder1/untracked &&
1239
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1240
+ run_on_all test_path_exists deep/untracked-deep/untracked &&
1241
+
1242
+ test_all_match git clean -fd &&
1243
+ test_all_match git status --porcelain=v2 &&
1244
+ test_sparse_match ls &&
1245
+ test_sparse_match ls folder1 &&
1246
+ run_on_all test_path_exists folder1/bogus &&
1247
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1248
+ run_on_all test_path_is_missing deep/untracked-deep/untracked &&
1233
1249
1234
1250
test_all_match git clean -xf &&
1235
1251
test_all_match git status --porcelain=v2 &&
1236
1252
test_sparse_match ls &&
1237
1253
test_sparse_match ls folder1 &&
1254
+ run_on_all test_path_is_missing folder1/bogus &&
1255
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1238
1256
1239
1257
test_all_match git clean -xdf &&
1240
1258
test_all_match git status --porcelain=v2 &&
1241
1259
test_sparse_match ls &&
1242
1260
test_sparse_match ls folder1 &&
1261
+ run_on_all test_path_is_missing deep/untracked-deep/bogus &&
1243
1262
1244
1263
test_sparse_match test_path_is_dir folder1
1245
1264
'
@@ -1405,6 +1424,8 @@ test_expect_success 'sparse-index is not expanded' '
1405
1424
git -C sparse-index add README.md &&
1406
1425
ensure_not_expanded diff --staged &&
1407
1426
1427
+ ensure_not_expanded clean -fd &&
1428
+
1408
1429
ensure_not_expanded reset base -- deep/a &&
1409
1430
ensure_not_expanded reset base -- nonexistent-file &&
1410
1431
ensure_not_expanded reset deepest -- deep &&
@@ -1674,6 +1695,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
1674
1695
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
1675
1696
'
1676
1697
1698
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1699
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1700
+ # applying a stash of untracked files. As a result, the test reports that it
1701
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1702
+ # performance implications of expanding the full repository index.
1703
+ test_expect_success ' sparse index is not expanded: stash -u' '
1704
+ init_repos &&
1705
+
1706
+ mkdir -p sparse-index/folder1 &&
1707
+ echo >>sparse-index/README.md &&
1708
+ echo >>sparse-index/a &&
1709
+ echo >>sparse-index/folder1/new &&
1710
+
1711
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1712
+ git -C sparse-index stash -u &&
1713
+ test_region index ensure_full_index trace2.txt &&
1714
+
1715
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1716
+ git -C sparse-index stash pop &&
1717
+ test_region index ensure_full_index trace2.txt
1718
+ '
1719
+
1720
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1721
+ # checkout definition are successfully stashed and unstashed.
1722
+ test_expect_success ' stash -u outside sparse checkout definition' '
1723
+ init_repos &&
1724
+
1725
+ write_script edit-contents <<-\EOF &&
1726
+ echo text >>$1
1727
+ EOF
1728
+
1729
+ run_on_sparse mkdir -p folder1 &&
1730
+ run_on_all ../edit-contents folder1/new &&
1731
+ test_all_match git stash -u &&
1732
+ test_all_match git status --porcelain=v2 &&
1733
+
1734
+ test_all_match git stash pop -q &&
1735
+ test_all_match git status --porcelain=v2
1736
+ '
1737
+
1677
1738
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1678
1739
# in this scenario, but it shouldn't.
1679
1740
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments