Git development
 help / color / mirror / Atom feed
From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>,
	 Jeff King <peff@peff.net>
Subject: Re: [PATCH v5 07/11] refs: move parsing of "core.logAllRefUpdates" back into ref stores
Date: Wed, 24 Jun 2026 16:22:07 -0500	[thread overview]
Message-ID: <ajxEXMTBmii01dVP@denethor> (raw)
In-Reply-To: <20260622-b4-pks-refs-avoid-chdir-notify-reparent-v5-7-018475013dbc@pks.im>

On 26/06/22 10:28AM, Patrick Steinhardt wrote:
> In cc42c88945 (refs: extract out reflog config to generic layer,
> 2026-05-04) we have refactored how we parse "core.logAllRefUpdates" so
> that it happens in the generic layer. Unfortunately, this has worsened a
> preexisting issue where we may recurse when creating the reference store
> because of a chicken-and-egg problem between parsing the configuration
> and evaluating "onbranch" conditions.

Ok so IIUC, parsing "core.logAllRefUpdates" in the generic layer forces
us to read the config earlier. This is problematic though since the
refstore has not been initialized yet which we need to evaluate
"onbranch" conditions.

> Prepare for a fix by essentially reverting that change so that we handle
> this setting in the respective backends again. The backends are already
> parsing other configuration anyway, so by moving the logic back in there
> we can ensure that all backend configuration is parsed the same way.

Makes sense.

> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/checkout.c      |  7 +++++--
>  refs.c                  | 10 +++++++++-
>  refs.h                  |  9 +++++++++
>  refs/files-backend.c    | 20 +++++++++++++++++---
>  refs/refs-internal.h    |  6 ------
>  refs/reftable-backend.c | 20 +++++++++++---------
>  repo-settings.c         | 16 ----------------
>  repo-settings.h         |  9 ---------
>  setup.c                 |  7 ++++++-
>  9 files changed, 57 insertions(+), 47 deletions(-)
> 
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index b78b3a1d16..aee84ca897 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -952,10 +952,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
>  	const char *old_desc, *reflog_msg;
>  	if (opts->new_branch) {
>  		if (opts->new_orphan_branch) {
> -			enum log_refs_config log_all_ref_updates =
> -				repo_settings_get_log_all_ref_updates(the_repository);
> +			enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;
> +			const char *value;
>  			char *refname;
>  
> +			if (!repo_config_get_string_tmp(the_repository, "core.logallrefupdates", &value))
> +				log_all_ref_updates = refs_parse_log_all_ref_updates_config(value);
> +
>  			refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
>  			if (opts->new_branch_log &&
>  			    !should_autocreate_reflog(log_all_ref_updates, refname)) {
> diff --git a/refs.c b/refs.c
> index d3caa9a633..5b773b1c15 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1053,6 +1053,15 @@ static char *normalize_reflog_message(const char *msg)
>  	return strbuf_detach(&sb, NULL);
>  }
>  
> +enum log_refs_config refs_parse_log_all_ref_updates_config(const char *value)
> +{
> +	if (value && !strcasecmp(value, "always"))
> +		return LOG_REFS_ALWAYS;
> +	else if (git_config_bool("core.logallrefupdates", value))
> +		return LOG_REFS_NORMAL;
> +	return LOG_REFS_NONE;
> +}

This function replaces `repo_settings_get_log_all_ref_updates()`. I
assume we just wanted a slightly more simple function where the only
concern was parsing the `core.logallrefupdates` value.

> +
>  int should_autocreate_reflog(enum log_refs_config log_all_ref_updates,
>  			     const char *refname)
>  {
> @@ -2327,7 +2336,6 @@ static struct ref_store *ref_store_init(struct repository *repo,
>  	struct ref_store *refs;
>  	struct ref_store_init_options opts = {
>  		.access_flags = flags,
> -		.log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo),

This config is no longer handled in the generic layer.

[snip]
> diff --git a/setup.c b/setup.c
> index 79125db565..0c6efb0560 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2584,10 +2584,15 @@ static int create_default_files(struct repository *repo,
>  	if (is_bare_repository())
>  		repo_config_set(repo, "core.bare", "true");
>  	else {
> +		const char *value;
> +
>  		repo_config_set(repo, "core.bare", "false");
> +
>  		/* allow template config file to override the default */
> -		if (repo_settings_get_log_all_ref_updates(repo) == LOG_REFS_UNSET)
> +		if (repo_config_get_string_tmp(repo, "core.logallrefupdates", &value) ||
> +		    refs_parse_log_all_ref_updates_config(value) == LOG_REFS_UNSET)

Huh, can `refs_parse_log_all_ref_updates_config()` even return
LOG_REFS_UNSET?

-Justin

  reply	other threads:[~2026-06-24 21:22 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 14:57 [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 1/9] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 2/9] setup: stop applying repository format twice Patrick Steinhardt
2026-06-12  9:00   ` Karthik Nayak
2026-06-15 12:36     ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 3/9] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-10 17:32   ` Junio C Hamano
2026-06-12  6:18     ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 4/9] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-12  9:18   ` Karthik Nayak
2026-06-15 12:36     ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 5/9] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 6/9] repository: free main reference database Patrick Steinhardt
2026-06-12  9:20   ` Karthik Nayak
2026-06-10 14:57 ` [PATCH 7/9] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 8/9] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 9/9] refs: always use absolute paths for reference stores Patrick Steinhardt
2026-06-12  9:58   ` Karthik Nayak
2026-06-15 12:36     ` Patrick Steinhardt
2026-06-11  6:53 ` [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Jeff King
2026-06-12  6:18   ` Patrick Steinhardt
2026-06-13 14:00     ` Jeff King
2026-06-15 12:36       ` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 0/8] " Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 1/8] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 2/8] setup: stop applying repository format twice Patrick Steinhardt
2026-06-17 17:22     ` Justin Tobler
2026-06-15 13:56   ` [PATCH v2 3/8] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-17 17:43     ` Justin Tobler
2026-06-18  6:53       ` Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 4/8] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-17 18:02     ` Justin Tobler
2026-06-17 18:07       ` Justin Tobler
2026-06-18  6:54       ` Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 5/8] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 6/8] repository: free main reference database Patrick Steinhardt
2026-06-17 18:09     ` Justin Tobler
2026-06-15 13:56   ` [PATCH v2 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-17 18:41     ` Justin Tobler
2026-06-18  5:59       ` Patrick Steinhardt
2026-06-18 14:15         ` Justin Tobler
2026-06-18 14:51           ` Patrick Steinhardt
2026-06-18 15:53             ` Justin Tobler
2026-06-18 16:40     ` Jeff King
2026-06-19  6:25       ` Patrick Steinhardt
2026-06-21 21:12         ` Jeff King
2026-06-22  5:15           ` Patrick Steinhardt
2026-06-15 13:56   ` [PATCH v2 8/8] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-18  6:54 ` [PATCH v3 0/8] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 1/8] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 2/8] setup: stop applying repository format twice Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 3/8] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 4/8] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 5/8] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 6/8] repository: free main reference database Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-18  6:54   ` [PATCH v3 8/8] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 00/10] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 01/10] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 02/10] setup: stop applying repository format twice Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 03/10] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 04/10] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 05/10] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 06/10] repository: free main reference database Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 07/10] refs: move parsing of "core.logAllRefUpdates" back into ref stores Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 08/10] refs/reftable-backend: manually parse "core.sharedRepository" Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 09/10] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-19 11:27   ` [PATCH v4 10/10] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-22  8:28 ` [PATCH v5 00/11] refs: fix "onbranch" conditions Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 01/11] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 02/11] setup: stop applying repository format twice Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 03/11] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 04/11] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 05/11] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 06/11] repository: free main reference database Patrick Steinhardt
2026-06-22  8:28   ` [PATCH v5 07/11] refs: move parsing of "core.logAllRefUpdates" back into ref stores Patrick Steinhardt
2026-06-24 21:22     ` Justin Tobler [this message]
2026-06-22  8:28   ` [PATCH v5 08/11] refs/files: lazy-load configuration to fix chicken-and-egg Patrick Steinhardt
2026-06-24 21:36     ` Justin Tobler
2026-06-22  8:28   ` [PATCH v5 09/11] reftable: split up write options Patrick Steinhardt
2026-06-24 22:06     ` Justin Tobler
2026-06-22  8:28   ` [PATCH v5 10/11] refs/reftable: lazy-load configuration to fix chicken-and-egg Patrick Steinhardt
2026-06-24 22:18     ` Justin Tobler
2026-06-22  8:28   ` [PATCH v5 11/11] refs: protect against chicken-and-egg recursion Patrick Steinhardt

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=ajxEXMTBmii01dVP@denethor \
    --to=jltobler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=peff@peff.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox