Skip to content

Commit 3ef0117

Browse files
vdyeldennington
authored andcommitted
clean: integrate with sparse index
Add repository setting to not require full index and test to verify index is not expanded in `git clean`. Existing test for `git clean` expanded to verify behavior when cleaning untracked files in sparse directories is consistent. Signed-off-by: Victoria Dye <[email protected]>
1 parent bcdd9df commit 3ef0117

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

builtin/clean.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
10361036
dir.flags |= DIR_KEEP_UNTRACKED_CONTENTS;
10371037
}
10381038

1039+
prepare_repo_settings(the_repository);
1040+
the_repository->settings.command_requires_full_index = 0;
1041+
10391042
if (read_cache() < 0)
10401043
die(_("index file corrupt"));
10411044
enable_fscache(active_nr);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,23 +1223,42 @@ test_expect_success 'clean' '
12231223
test_all_match git commit -m "ignore bogus files" &&
12241224
12251225
run_on_sparse mkdir folder1 &&
1226+
run_on_all mkdir -p deep/untracked-deep &&
12261227
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 &&
12271231
12281232
test_all_match git status --porcelain=v2 &&
12291233
test_all_match git clean -f &&
12301234
test_all_match git status --porcelain=v2 &&
12311235
test_sparse_match ls &&
12321236
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 &&
12331249
12341250
test_all_match git clean -xf &&
12351251
test_all_match git status --porcelain=v2 &&
12361252
test_sparse_match ls &&
12371253
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 &&
12381256
12391257
test_all_match git clean -xdf &&
12401258
test_all_match git status --porcelain=v2 &&
12411259
test_sparse_match ls &&
12421260
test_sparse_match ls folder1 &&
1261+
run_on_all test_path_is_missing deep/untracked-deep/bogus &&
12431262
12441263
test_sparse_match test_path_is_dir folder1
12451264
'
@@ -1405,6 +1424,8 @@ test_expect_success 'sparse-index is not expanded' '
14051424
git -C sparse-index add README.md &&
14061425
ensure_not_expanded diff --staged &&
14071426
1427+
ensure_not_expanded clean -fd &&
1428+
14081429
ensure_not_expanded reset base -- deep/a &&
14091430
ensure_not_expanded reset base -- nonexistent-file &&
14101431
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)