Merge branch 'es/mark-gc-cruft-as-experimental'
Enable gc.cruftpacks by default for those who opt into feature.experimental setting. * es/mark-gc-cruft-as-experimental: config: let feature.experimental imply gc.cruftPacks=true gc: add tests for --cruft and friends
This commit is contained in:
commit
bdd42e34e3
@ -14,6 +14,9 @@ feature.experimental::
|
|||||||
+
|
+
|
||||||
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
|
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
|
||||||
skipping more commits at a time, reducing the number of round trips.
|
skipping more commits at a time, reducing the number of round trips.
|
||||||
|
+
|
||||||
|
* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
|
||||||
|
garbage collection, preventing loose object explosions.
|
||||||
|
|
||||||
feature.manyFiles::
|
feature.manyFiles::
|
||||||
Enable config options that optimize for repos with many files in the
|
Enable config options that optimize for repos with many files in the
|
||||||
|
@ -42,7 +42,7 @@ static const char * const builtin_gc_usage[] = {
|
|||||||
|
|
||||||
static int pack_refs = 1;
|
static int pack_refs = 1;
|
||||||
static int prune_reflogs = 1;
|
static int prune_reflogs = 1;
|
||||||
static int cruft_packs = 0;
|
static int cruft_packs = -1;
|
||||||
static int aggressive_depth = 50;
|
static int aggressive_depth = 50;
|
||||||
static int aggressive_window = 250;
|
static int aggressive_window = 250;
|
||||||
static int gc_auto_threshold = 6700;
|
static int gc_auto_threshold = 6700;
|
||||||
@ -593,6 +593,10 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
|
|||||||
if (prune_expire && parse_expiry_date(prune_expire, &dummy))
|
if (prune_expire && parse_expiry_date(prune_expire, &dummy))
|
||||||
die(_("failed to parse prune expiry value %s"), prune_expire);
|
die(_("failed to parse prune expiry value %s"), prune_expire);
|
||||||
|
|
||||||
|
prepare_repo_settings(the_repository);
|
||||||
|
if (cruft_packs < 0)
|
||||||
|
cruft_packs = the_repository->settings.gc_cruft_packs;
|
||||||
|
|
||||||
if (aggressive) {
|
if (aggressive) {
|
||||||
strvec_push(&repack, "-f");
|
strvec_push(&repack, "-f");
|
||||||
if (aggressive_depth > 0)
|
if (aggressive_depth > 0)
|
||||||
@ -704,7 +708,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
|
|||||||
clean_pack_garbage();
|
clean_pack_garbage();
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_repo_settings(the_repository);
|
|
||||||
if (the_repository->settings.gc_write_commit_graph == 1)
|
if (the_repository->settings.gc_write_commit_graph == 1)
|
||||||
write_commit_graph_reachable(the_repository->objects->odb,
|
write_commit_graph_reachable(the_repository->objects->odb,
|
||||||
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
|
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
|
||||||
|
@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
|
|||||||
/* Defaults modified by feature.* */
|
/* Defaults modified by feature.* */
|
||||||
if (experimental) {
|
if (experimental) {
|
||||||
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
|
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
|
||||||
|
r->settings.gc_cruft_packs = 1;
|
||||||
}
|
}
|
||||||
if (manyfiles) {
|
if (manyfiles) {
|
||||||
r->settings.index_version = 4;
|
r->settings.index_version = 4;
|
||||||
|
@ -34,6 +34,7 @@ struct repo_settings {
|
|||||||
int commit_graph_generation_version;
|
int commit_graph_generation_version;
|
||||||
int commit_graph_read_changed_paths;
|
int commit_graph_read_changed_paths;
|
||||||
int gc_write_commit_graph;
|
int gc_write_commit_graph;
|
||||||
|
int gc_cruft_packs;
|
||||||
int fetch_write_commit_graph;
|
int fetch_write_commit_graph;
|
||||||
int command_requires_full_index;
|
int command_requires_full_index;
|
||||||
int sparse_index;
|
int sparse_index;
|
||||||
|
@ -202,6 +202,102 @@ test_expect_success 'one of gc.reflogExpire{Unreachable,}=never does not skip "e
|
|||||||
grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out
|
grep -E "^trace: (built-in|exec|run_command): git reflog expire --" trace.out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
prepare_cruft_history () {
|
||||||
|
test_commit base &&
|
||||||
|
|
||||||
|
test_commit --no-tag foo &&
|
||||||
|
test_commit --no-tag bar &&
|
||||||
|
git reset HEAD^^
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_cruft_packs () {
|
||||||
|
find .git/objects/pack -name "*.mtimes" >mtimes &&
|
||||||
|
sed -e 's/\.mtimes$/\.pack/g' mtimes >packs &&
|
||||||
|
|
||||||
|
test_file_not_empty packs &&
|
||||||
|
while read pack
|
||||||
|
do
|
||||||
|
test_path_is_file "$pack" || return 1
|
||||||
|
done <packs
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_no_cruft_packs () {
|
||||||
|
find .git/objects/pack -name "*.mtimes" >mtimes &&
|
||||||
|
test_must_be_empty mtimes
|
||||||
|
}
|
||||||
|
|
||||||
|
test_expect_success 'gc --cruft generates a cruft pack' '
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
git init crufts &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git gc --cruft &&
|
||||||
|
assert_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
git init crufts &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git -c gc.cruftPacks=true gc &&
|
||||||
|
assert_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'feature.experimental=true generates a cruft pack' '
|
||||||
|
git init crufts &&
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git -c feature.experimental=true gc &&
|
||||||
|
assert_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'feature.experimental=false allows explicit cruft packs' '
|
||||||
|
git init crufts &&
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git -c gc.cruftPacks=true -c feature.experimental=false gc &&
|
||||||
|
assert_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'feature.experimental=true can be overridden' '
|
||||||
|
git init crufts &&
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git -c feature.expiremental=true -c gc.cruftPacks=false gc &&
|
||||||
|
assert_no_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'feature.experimental=false avoids cruft packs by default' '
|
||||||
|
git init crufts &&
|
||||||
|
test_when_finished "rm -fr crufts" &&
|
||||||
|
(
|
||||||
|
cd crufts &&
|
||||||
|
|
||||||
|
prepare_cruft_history &&
|
||||||
|
git -c feature.experimental=false gc &&
|
||||||
|
assert_no_cruft_packs
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
run_and_wait_for_auto_gc () {
|
run_and_wait_for_auto_gc () {
|
||||||
# We read stdout from gc for the side effect of waiting until the
|
# We read stdout from gc for the side effect of waiting until the
|
||||||
# background gc process exits, closing its fd 9. Furthermore, the
|
# background gc process exits, closing its fd 9. Furthermore, the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user