@@ -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
'
@@ -1202,6 +1221,8 @@ test_expect_success 'sparse-index is not expanded' '
1202
1221
git -C sparse-index add README.md &&
1203
1222
ensure_not_expanded diff --staged &&
1204
1223
1224
+ ensure_not_expanded clean -fd &&
1225
+
1205
1226
ensure_not_expanded checkout -f update-deep &&
1206
1227
(
1207
1228
sane_unset GIT_TEST_MERGE_ALGORITHM &&
@@ -1280,6 +1301,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
1280
1301
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
1281
1302
'
1282
1303
1304
+ # NEEDSWORK: although the full repository's index is _not_ expanded as part of
1305
+ # stash, a temporary index, which is _not_ sparse, is created when stashing and
1306
+ # applying a stash of untracked files. As a result, the test reports that it
1307
+ # finds an instance of `ensure_full_index`, but it does not carry with it the
1308
+ # performance implications of expanding the full repository index.
1309
+ test_expect_success ' sparse index is not expanded: stash -u' '
1310
+ init_repos &&
1311
+
1312
+ mkdir -p sparse-index/folder1 &&
1313
+ echo >>sparse-index/README.md &&
1314
+ echo >>sparse-index/a &&
1315
+ echo >>sparse-index/folder1/new &&
1316
+
1317
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1318
+ git -C sparse-index stash -u &&
1319
+ test_region index ensure_full_index trace2.txt &&
1320
+
1321
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
1322
+ git -C sparse-index stash pop &&
1323
+ test_region index ensure_full_index trace2.txt
1324
+ '
1325
+
1326
+ # NEEDSWORK: similar to `git add`, untracked files outside of the sparse
1327
+ # checkout definition are successfully stashed and unstashed.
1328
+ test_expect_success ' stash -u outside sparse checkout definition' '
1329
+ init_repos &&
1330
+
1331
+ write_script edit-contents <<-\EOF &&
1332
+ echo text >>$1
1333
+ EOF
1334
+
1335
+ run_on_sparse mkdir -p folder1 &&
1336
+ run_on_all ../edit-contents folder1/new &&
1337
+ test_all_match git stash -u &&
1338
+ test_all_match git status --porcelain=v2 &&
1339
+
1340
+ test_all_match git stash pop -q &&
1341
+ test_all_match git status --porcelain=v2
1342
+ '
1343
+
1283
1344
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1284
1345
# in this scenario, but it shouldn't.
1285
1346
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments