Skip to content

Commit 307ee2b

Browse files
vdyederrickstolee
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 9d20b37 commit 307ee2b

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
@@ -1111,23 +1111,42 @@ test_expect_success 'clean' '
11111111
test_all_match git commit -m "ignore bogus files" &&
11121112
11131113
run_on_sparse mkdir folder1 &&
1114+
run_on_all mkdir -p deep/untracked-deep &&
11141115
run_on_all touch folder1/bogus &&
1116+
run_on_all touch folder1/untracked &&
1117+
run_on_all touch deep/untracked-deep/bogus &&
1118+
run_on_all touch deep/untracked-deep/untracked &&
11151119
11161120
test_all_match git status --porcelain=v2 &&
11171121
test_all_match git clean -f &&
11181122
test_all_match git status --porcelain=v2 &&
11191123
test_sparse_match ls &&
11201124
test_sparse_match ls folder1 &&
1125+
run_on_all test_path_exists folder1/bogus &&
1126+
run_on_all test_path_is_missing folder1/untracked &&
1127+
run_on_all test_path_exists deep/untracked-deep/bogus &&
1128+
run_on_all test_path_exists deep/untracked-deep/untracked &&
1129+
1130+
test_all_match git clean -fd &&
1131+
test_all_match git status --porcelain=v2 &&
1132+
test_sparse_match ls &&
1133+
test_sparse_match ls folder1 &&
1134+
run_on_all test_path_exists folder1/bogus &&
1135+
run_on_all test_path_exists deep/untracked-deep/bogus &&
1136+
run_on_all test_path_is_missing deep/untracked-deep/untracked &&
11211137
11221138
test_all_match git clean -xf &&
11231139
test_all_match git status --porcelain=v2 &&
11241140
test_sparse_match ls &&
11251141
test_sparse_match ls folder1 &&
1142+
run_on_all test_path_is_missing folder1/bogus &&
1143+
run_on_all test_path_exists deep/untracked-deep/bogus &&
11261144
11271145
test_all_match git clean -xdf &&
11281146
test_all_match git status --porcelain=v2 &&
11291147
test_sparse_match ls &&
11301148
test_sparse_match ls folder1 &&
1149+
run_on_all test_path_is_missing deep/untracked-deep/bogus &&
11311150
11321151
test_sparse_match test_path_is_dir folder1
11331152
'
@@ -1251,6 +1270,8 @@ test_expect_success 'sparse-index is not expanded' '
12511270
git -C sparse-index add README.md &&
12521271
ensure_not_expanded diff --staged &&
12531272
1273+
ensure_not_expanded clean -fd &&
1274+
12541275
ensure_not_expanded reset base -- deep/a &&
12551276
ensure_not_expanded reset base -- nonexistent-file &&
12561277
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)