All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/7] refs/packed: de-globalize handling of "core.packedRefsTimeout"
Date: Thu, 09 Jul 2026 11:52:11 -0700	[thread overview]
Message-ID: <xmqq7bn4ov1g.fsf@gitster.g> (raw)
In-Reply-To: <20260709-pks-refs-wo-the-repository-v1-1-1ad6f27529c9@pks.im> (Patrick Steinhardt's message of "Thu, 09 Jul 2026 10:29:12 +0200")

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?

Thanks.

> @@ -1249,7 +1254,7 @@ int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err)
>  	if (hold_lock_file_for_update_timeout(
>  			    &refs->lock,
>  			    refs->path,
> -			    flags, timeout_value) < 0) {
> +			    flags, refs->timeout_value) < 0) {
>  		unable_to_lock_message(refs->path, errno, err);
>  		return -1;
>  	}

  reply	other threads:[~2026-07-09 18:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  8:29 [PATCH 0/7] refs: remove use of `the_repository` Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 1/7] refs/packed: de-globalize handling of "core.packedRefsTimeout" Patrick Steinhardt
2026-07-09 18:52   ` Junio C Hamano [this message]
2026-07-10  5:56     ` Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 2/7] refs/packed: drop `USE_THE_REPOSITORY_VARIABLE` Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 3/7] refs/files: " Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 4/7] worktree: refactor code to use available repositories Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 5/7] worktree: pass repository to file-local functions Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 6/7] worktree: pass repository to public functions Patrick Steinhardt
2026-07-09  8:29 ` [PATCH 7/7] refs: remove remaining uses of `the_repository` Patrick Steinhardt
2026-07-09 20:39 ` [PATCH 0/7] refs: remove use " Junio C Hamano
2026-07-10  5:56   ` Patrick Steinhardt
2026-07-10  6:14     ` Patrick Steinhardt
2026-07-10 16:57       ` Junio C Hamano
2026-07-10 20:24         ` Junio C Hamano
2026-07-10 14:48     ` 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=xmqq7bn4ov1g.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.