@@ -1068,23 +1068,42 @@ test_expect_success 'clean' '
1068
1068
test_all_match git commit -m "ignore bogus files" &&
1069
1069
1070
1070
run_on_sparse mkdir folder1 &&
1071
+ run_on_all mkdir -p deep/untracked-deep &&
1071
1072
run_on_all touch folder1/bogus &&
1073
+ run_on_all touch folder1/untracked &&
1074
+ run_on_all touch deep/untracked-deep/bogus &&
1075
+ run_on_all touch deep/untracked-deep/untracked &&
1072
1076
1073
1077
test_all_match git status --porcelain=v2 &&
1074
1078
test_all_match git clean -f &&
1075
1079
test_all_match git status --porcelain=v2 &&
1076
1080
test_sparse_match ls &&
1077
1081
test_sparse_match ls folder1 &&
1082
+ run_on_all test_path_exists folder1/bogus &&
1083
+ run_on_all test_path_is_missing folder1/untracked &&
1084
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1085
+ run_on_all test_path_exists deep/untracked-deep/untracked &&
1086
+
1087
+ test_all_match git clean -fd &&
1088
+ test_all_match git status --porcelain=v2 &&
1089
+ test_sparse_match ls &&
1090
+ test_sparse_match ls folder1 &&
1091
+ run_on_all test_path_exists folder1/bogus &&
1092
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1093
+ run_on_all test_path_is_missing deep/untracked-deep/untracked &&
1078
1094
1079
1095
test_all_match git clean -xf &&
1080
1096
test_all_match git status --porcelain=v2 &&
1081
1097
test_sparse_match ls &&
1082
1098
test_sparse_match ls folder1 &&
1099
+ run_on_all test_path_is_missing folder1/bogus &&
1100
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1083
1101
1084
1102
test_all_match git clean -xdf &&
1085
1103
test_all_match git status --porcelain=v2 &&
1086
1104
test_sparse_match ls &&
1087
1105
test_sparse_match ls folder1 &&
1106
+ run_on_all test_path_is_missing deep/untracked-deep/bogus &&
1088
1107
1089
1108
test_sparse_match test_path_is_dir folder1
1090
1109
'
@@ -1206,6 +1225,8 @@ test_expect_success 'sparse-index is not expanded' '
1206
1225
git -C sparse-index add README.md &&
1207
1226
ensure_not_expanded diff --staged &&
1208
1227
1228
+ ensure_not_expanded clean -fd &&
1229
+
1209
1230
ensure_not_expanded reset base -- deep/a &&
1210
1231
ensure_not_expanded reset base -- nonexistent-file &&
1211
1232
ensure_not_expanded reset deepest -- deep &&
@@ -1300,6 +1321,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
1300
1321
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
1301
1322
'
1302
1323
1324
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1325
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1326
+ # applying a stash of untracked files. As a result, the test reports that it
1327
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1328
+ # performance implications of expanding the full repository index.
1329
+ test_expect_success ' sparse index is not expanded: stash -u' '
1330
+ init_repos &&
1331
+
1332
+ mkdir -p sparse-index/folder1 &&
1333
+ echo >>sparse-index/README.md &&
1334
+ echo >>sparse-index/a &&
1335
+ echo >>sparse-index/folder1/new &&
1336
+
1337
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1338
+ git -C sparse-index stash -u &&
1339
+ test_region index ensure_full_index trace2.txt &&
1340
+
1341
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1342
+ git -C sparse-index stash pop &&
1343
+ test_region index ensure_full_index trace2.txt
1344
+ '
1345
+
1346
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1347
+ # checkout definition are successfully stashed and unstashed.
1348
+ test_expect_success ' stash -u outside sparse checkout definition' '
1349
+ init_repos &&
1350
+
1351
+ write_script edit-contents <<-\EOF &&
1352
+ echo text >>$1
1353
+ EOF
1354
+
1355
+ run_on_sparse mkdir -p folder1 &&
1356
+ run_on_all ../edit-contents folder1/new &&
1357
+ test_all_match git stash -u &&
1358
+ test_all_match git status --porcelain=v2 &&
1359
+
1360
+ test_all_match git stash pop -q &&
1361
+ test_all_match git status --porcelain=v2
1362
+ '
1363
+
1303
1364
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1304
1365
# in this scenario, but it shouldn't.
1305
1366
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments