Skip to content

Commit 1e9e10e

Browse files
vdyegitster
authored andcommitted
clean: integrate with sparse index
Remove full index requirement for `git clean` and test to ensure the index is not expanded in `git clean`. Add to existing test for `git clean` to verify cleanup of untracked files in sparse directories is consistent between sparse index and non-sparse index checkouts. Signed-off-by: Victoria Dye <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1624333 commit 1e9e10e

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
@@ -983,6 +983,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
983983
dir.flags |= DIR_KEEP_UNTRACKED_CONTENTS;
984984
}
985985

986+
prepare_repo_settings(the_repository);
987+
the_repository->settings.command_requires_full_index = 0;
988+
986989
if (read_cache() < 0)
987990
die(_("index file corrupt"));
988991

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,23 +764,42 @@ test_expect_success 'clean' '
764764
test_all_match git commit -m "ignore bogus files" &&
765765
766766
run_on_sparse mkdir folder1 &&
767+
run_on_all mkdir -p deep/untracked-deep &&
767768
run_on_all touch folder1/bogus &&
769+
run_on_all touch folder1/untracked &&
770+
run_on_all touch deep/untracked-deep/bogus &&
771+
run_on_all touch deep/untracked-deep/untracked &&
768772
769773
test_all_match git status --porcelain=v2 &&
770774
test_all_match git clean -f &&
771775
test_all_match git status --porcelain=v2 &&
772776
test_sparse_match ls &&
773777
test_sparse_match ls folder1 &&
778+
run_on_all test_path_exists folder1/bogus &&
779+
run_on_all test_path_is_missing folder1/untracked &&
780+
run_on_all test_path_exists deep/untracked-deep/bogus &&
781+
run_on_all test_path_exists deep/untracked-deep/untracked &&
782+
783+
test_all_match git clean -fd &&
784+
test_all_match git status --porcelain=v2 &&
785+
test_sparse_match ls &&
786+
test_sparse_match ls folder1 &&
787+
run_on_all test_path_exists folder1/bogus &&
788+
run_on_all test_path_exists deep/untracked-deep/bogus &&
789+
run_on_all test_path_is_missing deep/untracked-deep/untracked &&
774790
775791
test_all_match git clean -xf &&
776792
test_all_match git status --porcelain=v2 &&
777793
test_sparse_match ls &&
778794
test_sparse_match ls folder1 &&
795+
run_on_all test_path_is_missing folder1/bogus &&
796+
run_on_all test_path_exists deep/untracked-deep/bogus &&
779797
780798
test_all_match git clean -xdf &&
781799
test_all_match git status --porcelain=v2 &&
782800
test_sparse_match ls &&
783801
test_sparse_match ls folder1 &&
802+
run_on_all test_path_is_missing deep/untracked-deep/bogus &&
784803
785804
test_sparse_match test_path_is_dir folder1
786805
'
@@ -920,6 +939,8 @@ test_expect_success 'sparse-index is not expanded' '
920939
# Wildcard identifies only full sparse directories, no index expansion
921940
ensure_not_expanded reset deepest -- folder\* &&
922941
942+
ensure_not_expanded clean -fd &&
943+
923944
ensure_not_expanded checkout -f update-deep &&
924945
test_config -C sparse-index pull.twohead ort &&
925946
(

0 commit comments

Comments
 (0)