Skip to content

Commit 626751a

Browse files
committed
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 43d600e commit 626751a

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
@@ -1010,6 +1010,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
10101010
dir.flags |= DIR_KEEP_UNTRACKED_CONTENTS;
10111011
}
10121012

1013+
prepare_repo_settings(the_repository);
1014+
the_repository->settings.command_requires_full_index = 0;
1015+
10131016
if (read_cache() < 0)
10141017
die(_("index file corrupt"));
10151018
enable_fscache(active_nr);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,23 +1068,42 @@ test_expect_success 'clean' '
10681068
test_all_match git commit -m "ignore bogus files" &&
10691069
10701070
run_on_sparse mkdir folder1 &&
1071+
run_on_all mkdir -p deep/untracked-deep &&
10711072
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 &&
10721076
10731077
test_all_match git status --porcelain=v2 &&
10741078
test_all_match git clean -f &&
10751079
test_all_match git status --porcelain=v2 &&
10761080
test_sparse_match ls &&
10771081
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 &&
10781094
10791095
test_all_match git clean -xf &&
10801096
test_all_match git status --porcelain=v2 &&
10811097
test_sparse_match ls &&
10821098
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 &&
10831101
10841102
test_all_match git clean -xdf &&
10851103
test_all_match git status --porcelain=v2 &&
10861104
test_sparse_match ls &&
10871105
test_sparse_match ls folder1 &&
1106+
run_on_all test_path_is_missing deep/untracked-deep/bogus &&
10881107
10891108
test_sparse_match test_path_is_dir folder1
10901109
'
@@ -1202,6 +1221,8 @@ test_expect_success 'sparse-index is not expanded' '
12021221
git -C sparse-index add README.md &&
12031222
ensure_not_expanded diff --staged &&
12041223
1224+
ensure_not_expanded clean -fd &&
1225+
12051226
ensure_not_expanded checkout -f update-deep &&
12061227
(
12071228
sane_unset GIT_TEST_MERGE_ALGORITHM &&

0 commit comments

Comments
 (0)