git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Taylor Blau" <me@ttaylorr.com>,
	git@vger.kernel.org, "Derrick Stolee" <derrickstolee@github.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Emily Shaffer" <emilyshaffer@google.com>
Subject: Re: [PATCH v2 2/2] config: let feature.experimental imply gc.cruftPacks=true
Date: Wed, 26 Oct 2022 17:32:51 -0400	[thread overview]
Message-ID: <Y1mng9cqAyEqQIQM@nand.local> (raw)
In-Reply-To: <xmqqfsfaffs1.fsf@gitster.g>

On Wed, Oct 26, 2022 at 02:15:10PM -0700, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > diff --git a/builtin/gc.c b/builtin/gc.c
> > index 243ee85d28..5a84f791ef 100644
> > --- a/builtin/gc.c
> > +++ b/builtin/gc.c
> > @@ -42,7 +42,7 @@ static const char * const builtin_gc_usage[] = {
> >
> >  static int pack_refs = 1;
> >  static int prune_reflogs = 1;
> > -static int cruft_packs = 0;
> > +static int cruft_packs = -1;
> >  static int aggressive_depth = 50;
> >  static int aggressive_window = 250;
> >  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))
> >  		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) {
> >  		strvec_push(&repack, "-f");
> >  		if (aggressive_depth > 0)
> > @@ -704,7 +708,6 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
> >  		clean_pack_garbage();
> >  	}
> >
> > -	prepare_repo_settings(the_repository);
>
> It is curious why we had this call so late in the sequence in the
> original.  This is well past what can be reasonably called "start-up".
> We have locked the repository, we may have daemonized ourselves, we
> may already have packed loose refs and pruned reflogs.  Was that due
> to somewhat lazy thinking that the next line is the first one that
> requires the repository's settings already prepared, I wonder.

The latter. The general practice I've observed with
prepare_repo_settings() is that it is supposed to be called lazily, just
before the first piece of code in a particular file that is going to
read the repo settings.

Since the function is a noop on any subsequent calls, we can afford to
be over-eager placing it around.

So it would have been equally OK to duplicate the call, but it's
unnecessary since the first call is entered unconditionally from within
cmd_gc().

> > +refute_cruft_packs_exist () {
> > +	find .git/objects/pack -name "*.mtimes" >mtimes &&
> > +	test_must_be_empty mtimes
> > +}
>
> Hmph, not "assert_no_cruft_packs"?

Heh, sorry :-).

> One thing missing is a test for the escape hatch for those who opt
> into the experimental world when gc.cruftPacks feature is broken.
> IOW,
>
> 	git -c feature.experimental=true -c gc.cruftPacks=false
>
> should allow them to opt out of gc.cruftPacks.
>
> Other than that, looking good.

Indeed, thanks for spotting it. I'll send a reroll with the additional
test.

Thanks,
Taylor

  reply	other threads:[~2022-10-26 21:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 20:13 [PATCH v2 0/2] gc: let feature.experimental imply gc.cruftPacks Taylor Blau
2022-10-26 20:13 ` [PATCH v2 1/2] gc: add tests for --cruft and friends Taylor Blau
2022-10-26 21:03   ` Junio C Hamano
2022-10-26 20:13 ` [PATCH v2 2/2] config: let feature.experimental imply gc.cruftPacks=true Taylor Blau
2022-10-26 21:15   ` Junio C Hamano
2022-10-26 21:32     ` Taylor Blau [this message]
2022-10-26 20:53 ` [PATCH v2 0/2] gc: let feature.experimental imply gc.cruftPacks Junio C Hamano
2022-10-26 21:32 ` [PATCH v3 " Taylor Blau
2022-10-26 21:32   ` [PATCH v3 1/2] gc: add tests for --cruft and friends Taylor Blau
2022-10-26 21:32   ` [PATCH v3 2/2] config: let feature.experimental imply gc.cruftPacks=true Taylor Blau
2022-10-31 10:46     ` Derrick Stolee

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1mng9cqAyEqQIQM@nand.local \
    --to=me@ttaylorr.com \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).