@@ -1123,23 +1123,42 @@ test_expect_success 'clean' '
1123
1123
test_all_match git commit -m "ignore bogus files" &&
1124
1124
1125
1125
run_on_sparse mkdir folder1 &&
1126
+ run_on_all mkdir -p deep/untracked-deep &&
1126
1127
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 &&
1127
1131
1128
1132
test_all_match git status --porcelain=v2 &&
1129
1133
test_all_match git clean -f &&
1130
1134
test_all_match git status --porcelain=v2 &&
1131
1135
test_sparse_match ls &&
1132
1136
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 &&
1133
1149
1134
1150
test_all_match git clean -xf &&
1135
1151
test_all_match git status --porcelain=v2 &&
1136
1152
test_sparse_match ls &&
1137
1153
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 &&
1138
1156
1139
1157
test_all_match git clean -xdf &&
1140
1158
test_all_match git status --porcelain=v2 &&
1141
1159
test_sparse_match ls &&
1142
1160
test_sparse_match ls folder1 &&
1161
+ run_on_all test_path_is_missing deep/untracked-deep/bogus &&
1143
1162
1144
1163
test_sparse_match test_path_is_dir folder1
1145
1164
'
@@ -1290,6 +1309,8 @@ test_expect_success 'sparse-index is not expanded' '
1290
1309
git -C sparse-index add README.md &&
1291
1310
ensure_not_expanded diff --staged &&
1292
1311
1312
+ ensure_not_expanded clean -fd &&
1313
+
1293
1314
ensure_not_expanded reset base -- deep/a &&
1294
1315
ensure_not_expanded reset base -- nonexistent-file &&
1295
1316
ensure_not_expanded reset deepest -- deep &&
@@ -1536,6 +1557,46 @@ test_expect_success 'sparse index is not expanded: read-tree' '
1536
1557
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest
1537
1558
'
1538
1559
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
+
1539
1600
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
1540
1601
# in this scenario, but it shouldn't.
1541
1602
test_expect_success ' reset mixed and checkout orphan' '
0 commit comments