Re: [PATCH 1/7] refs/packed: de-globalize handling of "core.packedRefsTimeout"
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jul 10, 2026, 05:56 UTC
- Message-ID
- <alCJpxAQwpTQ4g93@pks.im>
- In-Reply-To
- <xmqq7bn4ov1g.fsf@gitster.g>
On Thu, Jul 09, 2026 at 11:52:11AM -0700, Junio C Hamano wrote:
Show 49 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
> > diff --git a/refs/packed-backend.c b/refs/packed-backend.c
> > index 499cb55dfa..5c49c06493 100644
> > --- a/refs/packed-backend.c
> > +++ b/refs/packed-backend.c
> > @@ -162,6 +162,13 @@ struct packed_ref_store {
> > * `packed_ref_store`) must not be freed.
> > */
> > struct tempfile *tempfile;
> > +
> > + /*
> > + * Timeout when taking the "packed-refs.lock" file. configurable via
> > + * "core.packedRefsTimeout".
> > + */
> > + bool timeout_configured;
> > + int timeout_value;
> > };
> >
> > /*
> > @@ -1233,12 +1240,10 @@ int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err)
> > struct packed_ref_store *refs =
> > packed_downcast(ref_store, REF_STORE_WRITE | REF_STORE_MAIN,
> > "packed_refs_lock");
> > - static int timeout_configured = 0;
> > - static int timeout_value = 1000;
> >
> > - if (!timeout_configured) {
> > - repo_config_get_int(the_repository, "core.packedrefstimeout", &timeout_value);
> > - timeout_configured = 1;
>
> In the original code, when core.packedrefstimeout is not configured,
> our call to repo_config_get_int() does not touch timeout_value. As
> a result, we get the static 1000 and flip the "configured" flag to
> prevent this _value from further getting updated.
>
> > + if (!refs->timeout_configured) {
> > + repo_config_get_int(ref_store->repo, "core.packedrefstimeout", &refs->timeout_value);
> > + refs->timeout_configured = true;
>
> But what happens in the new code when core.packedrefstimeout is not
> configured? It is up to whoever initialised refs->timeout_value.
>
> If I am not mistaken, packed_ref_store_init() does xcalloc(), lets
> base_ref_store_init() initialise some members, initialises a few
> members itself (such as .store_flags and .path), and leaves other
> members, including .timeout_configured and .timeout_value,
> NUL-filled. .timeout_configured starting as false is perfectly
> fine, but shouldn't we initialise .timeout_value to 1000 as before?Ugh, we should. That's what happens when you tack on a last-minute patch to a series you had sitting around for weeks. Thanks for noticing!
Patrick