From: Junio C Hamano <gitster@pobox.com>
To: Emily Shaffer <emilyshaffer@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] config: let feature.experimental imply gc.cruftPacks=true
Date: Wed, 03 Aug 2022 15:05:47 -0700 [thread overview]
Message-ID: <xmqqfsid7zk4.fsf@gitster.g> (raw)
In-Reply-To: <20220803205721.3686361-3-emilyshaffer@google.com> (Emily Shaffer's message of "Wed, 3 Aug 2022 13:57:21 -0700")
Emily Shaffer <emilyshaffer@google.com> writes:
> +* `gc.cruftPacks=true` reduces disk space used by unreachable objects during
> +garbage collection.
OK.
> diff --git a/builtin/gc.c b/builtin/gc.c
> index eeff2b760e..919cc508c5 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -136,6 +136,7 @@ static int gc_config_is_timestamp_never(const char *var)
> static void gc_config(void)
> {
> const char *value;
> + int experimental = 0;
>
> if (!git_config_get_value("gc.packrefs", &value)) {
> if (value && !strcmp(value, "notbare"))
> @@ -148,6 +149,11 @@ static void gc_config(void)
> gc_config_is_timestamp_never("gc.reflogexpireunreachable"))
> prune_reflogs = 0;
>
> + /* feature.experimental implies gc.cruftPacks=true */
> + git_config_get_bool("feature.experimental", &experimental);
> + if (experimental)
> + cruft_packs = 1;
> +
I suspect the whole thing can just be:
git_config_get_bool("feature.experimental", &cruft_packs);
If there is no feature.experimental configuration, the call returns
non-zero (we do not check, though) without touching &cruft_packs, if
there is feature.experimental configuration, the call returns zero
(we do not check, though) and cruft_packs is set to either true
(when experimental) or false (otherwise).
And this whole thing happens before we inspect what the more
specific configuration gc.cruftPacks says, so...
> diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
> index e4c2c3583d..4ab6750111 100755
> --- a/t/t6500-gc.sh
> +++ b/t/t6500-gc.sh
> @@ -238,6 +238,41 @@ test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
> )
> '
>
> +test_expect_success 'feature.experimental=true generates a cruft pack' '
> + git init crufts &&
> + test_when_finished "rm -fr crufts" &&
> + (
> + cd crufts &&
> + test_commit base &&
> +
> + test_commit --no-tag foo &&
> + test_commit --no-tag bar &&
> + git reset HEAD^^ &&
> +
> + git -c feature.experimental=true gc &&
> +
> + cruft=$(basename $(ls .git/objects/pack/pack-*.mtimes) .mtimes) &&
> + test_path_is_file .git/objects/pack/$cruft.pack
> + )
> +'
> +
> +test_expect_success 'feature.experimental=false allows explicit cruft packs' '
> + git init crufts &&
> + test_when_finished "rm -fr crufts" &&
> + (
> + cd crufts &&
> + test_commit base &&
> +
> + test_commit --no-tag foo &&
> + test_commit --no-tag bar &&
> + git reset HEAD^^ &&
> +
> + git -c gc.cruftPacks=true -c feature.experimental=false gc &&
OK.
What is not tested is setting feature.experimental explicitly to
false without touching gc.cruftPacks does not use the cruft pack.
next prev parent reply other threads:[~2022-08-03 22:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 20:57 [PATCH 0/2] let feature.experimental imply gc.cruftPacks=true Emily Shaffer
2022-08-03 20:57 ` [PATCH 1/2] gc: add tests for --cruft and friends Emily Shaffer
2022-08-03 21:56 ` Junio C Hamano
2022-08-04 7:48 ` Ævar Arnfjörð Bjarmason
2022-08-04 16:09 ` Junio C Hamano
2022-08-03 20:57 ` [PATCH 2/2] config: let feature.experimental imply gc.cruftPacks=true Emily Shaffer
2022-08-03 22:05 ` Junio C Hamano [this message]
2022-08-04 13:05 ` Derrick Stolee
2022-08-04 16:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfsid7zk4.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).