Skip to content

Commit c695592

Browse files
nasamuffingitster
authored andcommitted
config: let feature.experimental imply gc.cruftPacks=true
We are interested in exploring whether gc.cruftPacks=true should become the default value. To determine whether it is safe to do so, let's encourage more users to try it out. Users who have set feature.experimental=true have already volunteered to try new and possibly-breaking config changes, so let's try this new default with that set of users. Signed-off-by: Emily Shaffer <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12253ab commit c695592

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

Documentation/config/feature.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ feature.experimental::
1414
+
1515
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
1616
skipping more commits at a time, reducing the number of round trips.
17+
+
18+
* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
19+
garbage collection, preventing loose object explosions.
1720

1821
feature.manyFiles::
1922
Enable config options that optimize for repos with many files in the

builtin/gc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const char * const builtin_gc_usage[] = {
4242

4343
static int pack_refs = 1;
4444
static int prune_reflogs = 1;
45-
static int cruft_packs = 0;
45+
static int cruft_packs = -1;
4646
static int aggressive_depth = 50;
4747
static int aggressive_window = 250;
4848
static int gc_auto_threshold = 6700;
@@ -600,6 +600,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
600600
if (prune_expire && parse_expiry_date(prune_expire, &dummy))
601601
die(_("failed to parse prune expiry value %s"), prune_expire);
602602

603+
prepare_repo_settings(the_repository);
604+
if (cruft_packs < 0)
605+
cruft_packs = the_repository->settings.gc_cruft_packs;
606+
603607
if (aggressive) {
604608
strvec_push(&repack, "-f");
605609
if (aggressive_depth > 0)
@@ -711,7 +715,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
711715
clean_pack_garbage();
712716
}
713717

714-
prepare_repo_settings(the_repository);
715718
if (the_repository->settings.gc_write_commit_graph == 1)
716719
write_commit_graph_reachable(the_repository->objects->odb,
717720
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,

repo-settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
4343
/* Defaults modified by feature.* */
4444
if (experimental) {
4545
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
46+
r->settings.gc_cruft_packs = 1;
4647
}
4748
if (manyfiles) {
4849
r->settings.index_version = 4;

repository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct repo_settings {
3333
int commit_graph_generation_version;
3434
int commit_graph_read_changed_paths;
3535
int gc_write_commit_graph;
36+
int gc_cruft_packs;
3637
int fetch_write_commit_graph;
3738
int command_requires_full_index;
3839
int sparse_index;

t/t6500-gc.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ assert_cruft_packs () {
221221
done <packs
222222
}
223223

224+
assert_no_cruft_packs () {
225+
find .git/objects/pack -name "*.mtimes" >mtimes &&
226+
test_must_be_empty mtimes
227+
}
228+
224229
test_expect_success 'gc --cruft generates a cruft pack' '
225230
test_when_finished "rm -fr crufts" &&
226231
git init crufts &&
@@ -245,6 +250,54 @@ test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
245250
)
246251
'
247252

253+
test_expect_success 'feature.experimental=true generates a cruft pack' '
254+
git init crufts &&
255+
test_when_finished "rm -fr crufts" &&
256+
(
257+
cd crufts &&
258+
259+
prepare_cruft_history &&
260+
git -c feature.experimental=true gc &&
261+
assert_cruft_packs
262+
)
263+
'
264+
265+
test_expect_success 'feature.experimental=false allows explicit cruft packs' '
266+
git init crufts &&
267+
test_when_finished "rm -fr crufts" &&
268+
(
269+
cd crufts &&
270+
271+
prepare_cruft_history &&
272+
git -c gc.cruftPacks=true -c feature.experimental=false gc &&
273+
assert_cruft_packs
274+
)
275+
'
276+
277+
test_expect_success 'feature.experimental=true can be overridden' '
278+
git init crufts &&
279+
test_when_finished "rm -fr crufts" &&
280+
(
281+
cd crufts &&
282+
283+
prepare_cruft_history &&
284+
git -c feature.expiremental=true -c gc.cruftPacks=false gc &&
285+
assert_no_cruft_packs
286+
)
287+
'
288+
289+
test_expect_success 'feature.experimental=false avoids cruft packs by default' '
290+
git init crufts &&
291+
test_when_finished "rm -fr crufts" &&
292+
(
293+
cd crufts &&
294+
295+
prepare_cruft_history &&
296+
git -c feature.experimental=false gc &&
297+
assert_no_cruft_packs
298+
)
299+
'
300+
248301
run_and_wait_for_auto_gc () {
249302
# We read stdout from gc for the side effect of waiting until the
250303
# background gc process exits, closing its fd 9. Furthermore, the

0 commit comments

Comments
 (0)