Skip to content

Commit f1661a8

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 1d21a03 commit f1661a8

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
@@ -1123,23 +1123,42 @@ test_expect_success 'clean' '
11231123
test_all_match git commit -m "ignore bogus files" &&
11241124
11251125
run_on_sparse mkdir folder1 &&
1126+
run_on_all mkdir -p deep/untracked-deep &&
11261127
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 &&
11271131
11281132
test_all_match git status --porcelain=v2 &&
11291133
test_all_match git clean -f &&
11301134
test_all_match git status --porcelain=v2 &&
11311135
test_sparse_match ls &&
11321136
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 &&
11331149
11341150
test_all_match git clean -xf &&
11351151
test_all_match git status --porcelain=v2 &&
11361152
test_sparse_match ls &&
11371153
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 &&
11381156
11391157
test_all_match git clean -xdf &&
11401158
test_all_match git status --porcelain=v2 &&
11411159
test_sparse_match ls &&
11421160
test_sparse_match ls folder1 &&
1161+
run_on_all test_path_is_missing deep/untracked-deep/bogus &&
11431162
11441163
test_sparse_match test_path_is_dir folder1
11451164
'
@@ -1290,6 +1309,8 @@ test_expect_success 'sparse-index is not expanded' '
12901309
git -C sparse-index add README.md &&
12911310
ensure_not_expanded diff --staged &&
12921311
1312+
ensure_not_expanded clean -fd &&
1313+
12931314
ensure_not_expanded reset base -- deep/a &&
12941315
ensure_not_expanded reset base -- nonexistent-file &&
12951316
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)