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

Re: [PATCH v5 07/11] refs: move parsing of "core.logAllRefUpdates" back into ref stores

From
Justin Tobler <jltobler@gmail.com>
Date
Jun 24, 2026, 21:22 UTC
Message-ID
<ajxEXMTBmii01dVP@denethor>
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:
Show 6 quoted lines
> 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.
Show 49 quoted lines
> 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.

Show 9 quoted lines
> +
>  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]
Show 16 quoted lines
> 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
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 77 of 88 in “refs: stop using `chdir_notify_reparent()`”
  1. 0/9 refs: stop using `chdir_notify_reparent()`Patrick Steinhardt, Jun 10, 2026
  2. 1/9 setup: inline `check_and_apply_repository_format()`Patrick Steinhardt, Jun 10, 2026
  3. 2/9 setup: stop applying repository format twicePatrick Steinhardt, Jun 10, 2026
  4. Karthik NayakJun 12, 2026
  5. Patrick SteinhardtJun 15, 2026
  6. 3/9 setup: don't apply "GIT_REFERENCE_BACKEND" without a repositoryPatrick Steinhardt, Jun 10, 2026
  7. Junio C HamanoJun 10, 2026
  8. Patrick SteinhardtJun 12, 2026
  9. 4/9 refs: unregister reference stores from "chdir_notify"Patrick Steinhardt, Jun 10, 2026
  10. Karthik NayakJun 12, 2026
  11. Patrick SteinhardtJun 15, 2026
  12. 5/9 chdir-notify: drop unused `chdir_notify_reparent()`Patrick Steinhardt, Jun 10, 2026
  13. 6/9 repository: free main reference databasePatrick Steinhardt, Jun 10, 2026
  14. Karthik NayakJun 12, 2026
  15. 7/9 refs: fix recursing `get_main_ref_store()` with "onbranch" configPatrick Steinhardt, Jun 10, 2026
  16. 8/9 refs: drop local buffer in `refs_compute_filesystem_location()`Patrick Steinhardt, Jun 10, 2026
  17. 9/9 refs: always use absolute paths for reference storesPatrick Steinhardt, Jun 10, 2026
  18. Karthik NayakJun 12, 2026
  19. Patrick SteinhardtJun 15, 2026
  20. Jeff KingJun 11, 2026
  21. Patrick SteinhardtJun 12, 2026
  22. Jeff KingJun 13, 2026
  23. Patrick SteinhardtJun 15, 2026
  24. 0/8 refs: stop using `chdir_notify_reparent()`Patrick Steinhardt, Jun 15, 2026
  25. 1/8 setup: inline `check_and_apply_repository_format()`Patrick Steinhardt, Jun 15, 2026
  26. 2/8 setup: stop applying repository format twicePatrick Steinhardt, Jun 15, 2026
  27. Justin ToblerJun 17, 2026
  28. 3/8 setup: don't apply "GIT_REFERENCE_BACKEND" without a repositoryPatrick Steinhardt, Jun 15, 2026
  29. Justin ToblerJun 17, 2026
  30. Patrick SteinhardtJun 18, 2026
  31. 4/8 refs: unregister reference stores from "chdir_notify"Patrick Steinhardt, Jun 15, 2026
  32. Justin ToblerJun 17, 2026
  33. Justin ToblerJun 17, 2026
  34. Patrick SteinhardtJun 18, 2026
  35. 5/8 chdir-notify: drop unused `chdir_notify_reparent()`Patrick Steinhardt, Jun 15, 2026
  36. 6/8 repository: free main reference databasePatrick Steinhardt, Jun 15, 2026
  37. Justin ToblerJun 17, 2026
  38. 7/8 refs: fix recursing `get_main_ref_store()` with "onbranch" configPatrick Steinhardt, Jun 15, 2026
  39. Justin ToblerJun 17, 2026
  40. Patrick SteinhardtJun 18, 2026
  41. Justin ToblerJun 18, 2026
  42. Patrick SteinhardtJun 18, 2026
  43. Justin ToblerJun 18, 2026
  44. Jeff KingJun 18, 2026
  45. Patrick SteinhardtJun 19, 2026
  46. Jeff KingJun 21, 2026
  47. Patrick SteinhardtJun 22, 2026
  48. 8/8 refs: drop local buffer in `refs_compute_filesystem_location()`Patrick Steinhardt, Jun 15, 2026
  49. 0/8 refs: stop using `chdir_notify_reparent()`Patrick Steinhardt, Jun 18, 2026
  50. 1/8 setup: inline `check_and_apply_repository_format()`Patrick Steinhardt, Jun 18, 2026
  51. 2/8 setup: stop applying repository format twicePatrick Steinhardt, Jun 18, 2026
  52. 3/8 setup: don't apply "GIT_REFERENCE_BACKEND" without a repositoryPatrick Steinhardt, Jun 18, 2026
  53. 4/8 refs: unregister reference stores from "chdir_notify"Patrick Steinhardt, Jun 18, 2026
  54. 5/8 chdir-notify: drop unused `chdir_notify_reparent()`Patrick Steinhardt, Jun 18, 2026
  55. 6/8 repository: free main reference databasePatrick Steinhardt, Jun 18, 2026
  56. 7/8 refs: fix recursing `get_main_ref_store()` with "onbranch" configPatrick Steinhardt, Jun 18, 2026
  57. 8/8 refs: drop local buffer in `refs_compute_filesystem_location()`Patrick Steinhardt, Jun 18, 2026
  58. 00/10 refs: stop using `chdir_notify_reparent()`Patrick Steinhardt, Jun 19, 2026
  59. 01/10 setup: inline `check_and_apply_repository_format()`Patrick Steinhardt, Jun 19, 2026
  60. 02/10 setup: stop applying repository format twicePatrick Steinhardt, Jun 19, 2026
  61. 03/10 setup: don't apply "GIT_REFERENCE_BACKEND" without a repositoryPatrick Steinhardt, Jun 19, 2026
  62. 04/10 refs: unregister reference stores from "chdir_notify"Patrick Steinhardt, Jun 19, 2026
  63. 05/10 chdir-notify: drop unused `chdir_notify_reparent()`Patrick Steinhardt, Jun 19, 2026
  64. 06/10 repository: free main reference databasePatrick Steinhardt, Jun 19, 2026
  65. 07/10 refs: move parsing of "core.logAllRefUpdates" back into ref storesPatrick Steinhardt, Jun 19, 2026
  66. 08/10 refs/reftable-backend: manually parse "core.sharedRepository"Patrick Steinhardt, Jun 19, 2026
  67. 09/10 refs: fix recursing `get_main_ref_store()` with "onbranch" configPatrick Steinhardt, Jun 19, 2026
  68. 10/10 refs: drop local buffer in `refs_compute_filesystem_location()`Patrick Steinhardt, Jun 19, 2026
  69. 00/11 refs: fix "onbranch" conditionsPatrick Steinhardt, Jun 22, 2026
  70. 01/11 setup: inline `check_and_apply_repository_format()`Patrick Steinhardt, Jun 22, 2026
  71. 02/11 setup: stop applying repository format twicePatrick Steinhardt, Jun 22, 2026
  72. 03/11 setup: don't apply "GIT_REFERENCE_BACKEND" without a repositoryPatrick Steinhardt, Jun 22, 2026
  73. 04/11 refs: unregister reference stores from "chdir_notify"Patrick Steinhardt, Jun 22, 2026
  74. 05/11 chdir-notify: drop unused `chdir_notify_reparent()`Patrick Steinhardt, Jun 22, 2026
  75. 06/11 repository: free main reference databasePatrick Steinhardt, Jun 22, 2026
  76. 07/11 refs: move parsing of "core.logAllRefUpdates" back into ref storesPatrick Steinhardt, Jun 22, 2026
  77. Justin ToblerJun 24, 2026
  78. Patrick SteinhardtJun 25, 2026
  79. 08/11 refs/files: lazy-load configuration to fix chicken-and-eggPatrick Steinhardt, Jun 22, 2026
  80. Justin ToblerJun 24, 2026
  81. Patrick SteinhardtJun 25, 2026
  82. 09/11 reftable: split up write optionsPatrick Steinhardt, Jun 22, 2026
  83. Justin ToblerJun 24, 2026
  84. Patrick SteinhardtJun 25, 2026
  85. 10/11 refs/reftable: lazy-load configuration to fix chicken-and-eggPatrick Steinhardt, Jun 22, 2026
  86. Justin ToblerJun 24, 2026
  87. Patrick SteinhardtJun 25, 2026
  88. 11/11 refs: protect against chicken-and-egg recursionPatrick Steinhardt, Jun 22, 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.