git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] builtin/maintenance: improve heuristic for "rerere gc"

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 4, 2026, 05:21 UTC
Message-ID
<appVVYr6oW0fyMRD@pks.im>
In-Reply-To
<2ca2b4db-1fd9-46e8-9385-260a12af43bb@gmail.com>
On Thu, Sep 03, 2026 at 10:19:33AM -0400, Derrick Stolee wrote:
Show 28 quoted lines
> On 9/3/2026 5:04 AM, Patrick Steinhardt wrote:
> > diff --git a/builtin/gc.c b/builtin/gc.c
> > index de2f9e7fed..9147418a61 100644
> > --- a/builtin/gc.c
> > +++ b/builtin/gc.c
> > @@ -396,31 +396,13 @@ static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED,
> >  
> >  static int rerere_gc_condition(struct gc_config *cfg UNUSED)
> >  {
> > -	struct strbuf path = STRBUF_INIT;
> > -	int should_gc = 0, limit = 1;
> > -	DIR *dir = NULL;
> > +	int limit = 512;
> >  
> >  	repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit);
> > +	if (limit <= 0)
> > +		return limit < 0;
> 
> This is cute, but works. It's logically equivalent to
> 
> 	if (!limit)
> 		return 0;
> 	if (limit < 0)
> 		return 1;
> 
> which would map more directly to the two documented cases. It takes
> the slightest amount of mental processing to connect the docs to
> the format you have.

This also existed in the preimage, but I agree it's harder to read than really necessary. Will improve while at it.

Show 9 quoted lines
> > +	return rerere_gc_estimate(the_repository, limit) >= (size_t)limit;
> >  }
> 
> I do like that this method is simpler in the builtin code in favor
> of a method that has access to rerere internals.
> 
> I do wonder if rerere_gc_estimate() should be
> rerere_stale_above_limit() instead, as we are not using any callers
> that care about the resulting number other than "is it at least limit?"

Agreed, the current name isn't great. I'm somehow hestitant to use `rerere_stale_above_limit()` too, though. I'll adapt it to `rerere_gc_needed()` instead.

Thanks for your review!
Patrick
Previous: Derrick StoleeNext: Thomas Bachem
Message 7 of 17 in “builtin/maintenance: improve heuristic for "rerere gc"”
  1. 0/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 3, 2026
  2. 1/2 rerere: extract logic to determine whether entries are stalePatrick Steinhardt, Sep 3, 2026
  3. Derrick StoleeSep 3, 2026
  4. Patrick SteinhardtSep 4, 2026
  5. 2/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 3, 2026
  6. Derrick StoleeSep 3, 2026
  7. Patrick SteinhardtSep 4, 2026
  8. Thomas BachemSep 3, 2026
  9. 0/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 4, 2026
  10. 1/2 rerere: extract logic to determine whether entries are stalePatrick Steinhardt, Sep 4, 2026
  11. 2/2 builtin/maintenance: improve heuristic for "rerere gc"Patrick Steinhardt, Sep 4, 2026
  12. Derrick StoleeSep 4, 2026
  13. Junio C HamanoSep 4, 2026
  14. Junio C HamanoSep 4, 2026
  15. Thomas BachemSep 4, 2026
  16. Patrick SteinhardtSep 7, 2026
  17. Patrick SteinhardtSep 7, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.