@@ -1111,23 +1111,42 @@ test_expect_success 'clean' '
1111
1111
test_all_match git commit -m "ignore bogus files" &&
1112
1112
1113
1113
run_on_sparse mkdir folder1 &&
1114
+ run_on_all mkdir -p deep/untracked-deep &&
1114
1115
run_on_all touch folder1/bogus &&
1116
+ run_on_all touch folder1/untracked &&
1117
+ run_on_all touch deep/untracked-deep/bogus &&
1118
+ run_on_all touch deep/untracked-deep/untracked &&
1115
1119
1116
1120
test_all_match git status --porcelain=v2 &&
1117
1121
test_all_match git clean -f &&
1118
1122
test_all_match git status --porcelain=v2 &&
1119
1123
test_sparse_match ls &&
1120
1124
test_sparse_match ls folder1 &&
1125
+ run_on_all test_path_exists folder1/bogus &&
1126
+ run_on_all test_path_is_missing folder1/untracked &&
1127
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1128
+ run_on_all test_path_exists deep/untracked-deep/untracked &&
1129
+
1130
+ test_all_match git clean -fd &&
1131
+ test_all_match git status --porcelain=v2 &&
1132
+ test_sparse_match ls &&
1133
+ test_sparse_match ls folder1 &&
1134
+ run_on_all test_path_exists folder1/bogus &&
1135
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1136
+ run_on_all test_path_is_missing deep/untracked-deep/untracked &&
1121
1137
1122
1138
test_all_match git clean -xf &&
1123
1139
test_all_match git status --porcelain=v2 &&
1124
1140
test_sparse_match ls &&
1125
1141
test_sparse_match ls folder1 &&
1142
+ run_on_all test_path_is_missing folder1/bogus &&
1143
+ run_on_all test_path_exists deep/untracked-deep/bogus &&
1126
1144
1127
1145
test_all_match git clean -xdf &&
1128
1146
test_all_match git status --porcelain=v2 &&
1129
1147
test_sparse_match ls &&
1130
1148
test_sparse_match ls folder1 &&
1149
+ run_on_all test_path_is_missing deep/untracked-deep/bogus &&
1131
1150
1132
1151
test_sparse_match test_path_is_dir folder1
1133
1152
'
@@ -1251,6 +1270,8 @@ test_expect_success 'sparse-index is not expanded' '
1251
1270
git -C sparse-index add README.md &&
1252
1271
ensure_not_expanded diff --staged &&
1253
1272
1273
+ ensure_not_expanded clean -fd &&
1274
+
1254
1275
ensure_not_expanded reset base -- deep/a &&
1255
1276
ensure_not_expanded reset base -- nonexistent-file &&
1256
1277
ensure_not_expanded reset deepest -- deep &&
@@ -1362,6 +1383,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
1362
1383
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
1363
1384
'
1364
1385
1386
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1387
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1388
+ # applying a stash of untracked files. As a result, the test reports that it
1389
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1390
+ # performance implications of expanding the full repository index.
1391
+ test_expect_success ' sparse index is not expanded: stash -u' '
1392
+ init_repos &&
1393
+
1394
+ mkdir -p sparse-index/folder1 &&
1395
+ echo >>sparse-index/README.md &&
1396
+ echo >>sparse-index/a &&
1397
+ echo >>sparse-index/folder1/new &&
1398
+
1399
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1400
+ git -C sparse-index stash -u &&
1401
+ test_region index ensure_full_index trace2.txt &&
1402
+
1403
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1404
+ git -C sparse-index stash pop &&
1405
+ test_region index ensure_full_index trace2.txt
1406
+ '
1407
+
1408
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1409
+ # checkout definition are successfully stashed and unstashed.
1410
+ test_expect_success ' stash -u outside sparse checkout definition' '
1411
+ init_repos &&
1412
+
1413
+ write_script edit-contents <<-\EOF &&
1414
+ echo text >>$1
1415
+ EOF
1416
+
1417
+ run_on_sparse mkdir -p folder1 &&
1418
+ run_on_all ../edit-contents folder1/new &&
1419
+ test_all_match git stash -u &&
1420
+ test_all_match git status --porcelain=v2 &&
1421
+
1422
+ test_all_match git stash pop -q &&
1423
+ test_all_match git status --porcelain=v2
1424
+ '
1425
+
1365
1426
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1366
1427
# in this scenario, but it shouldn't.
1367
1428
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments