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

Re: [PATCH 2/8] refs: extract out reflog config to generic layer

From
Karthik Nayak <karthik.188@gmail.com>
Date
Apr 22, 2026, 13:13 UTC
Message-ID
<CAOLa=ZTvYEzFrLCgJm6hVXUppHKCwPBws9eZeiBYbx2o8EaT_w@mail.gmail.com>
In-Reply-To
<aeit0pw44IxBfc2J@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 5 quoted lines
> On Mon, Apr 20, 2026 at 12:12:00PM +0200, Karthik Nayak wrote:
>> The reference backends need to know when to create reflog entries, this
>
> s/this/which/
>
Better.
>> is dictated by the 'core.logallrefupdates' config. Instead of relying on
>
> s/dictated/controlled/
>

Both of those mean the same. I guess there is a negative connotation to using the word 'dictated', but that's present with 'controlled' too. Perhaps 'determined'?

Show 32 quoted lines
>> the backends to call `repo_settings_get_log_all_ref_updates()` to obtain
>> this config value, let's do this in the generic layer and pass down the
>> value to the backends.
>>
>> Instead of passing this in as a new argument, let's create a new
>> `ref_init_options` structure which will house information required to
>> initialize a reference backend. Move the access flags here as well.
>
> I agree with this direction. It's also something that I'm doing for many
> callbacks in the ODB layer, and I'm moving more and more into that
> direction.
>
>> diff --git a/refs.c b/refs.c
>> index bfcb9c7ac3..aa66c6b28e 100644
>> --- a/refs.c
>> +++ b/refs.c
>> @@ -2295,6 +2295,10 @@ static struct ref_store *ref_store_init(struct repository *repo,
>>  {
>>  	const struct ref_storage_be *be;
>>  	struct ref_store *refs;
>> +	struct ref_store_init_options options = {
>> +		.access_flags = flags,
>> +		.log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo),
>> +	};
>>
>>  	be = find_ref_storage_backend(format);
>>  	if (!be)
>
> Tiniest nit, please feel free to ignore: we often call the structure
> itself `_options`, but the variables just `opts`. May just be my own
> preference though.
>
Let's make it consistent, I'll also start using `opts`.
Show 27 quoted lines
>> diff --git a/refs/refs-internal.h b/refs/refs-internal.h
>> index 2d963cc4f4..eed13af4eb 100644
>> --- a/refs/refs-internal.h
>> +++ b/refs/refs-internal.h
>> @@ -385,6 +385,21 @@ struct ref_store;
>>  				 REF_STORE_ODB | \
>>  				 REF_STORE_MAIN)
>>
>> +/*
>> + * Options for initializing the ref backend. All backend-agnostic information
>> + * which backends required will be held here.
>> + */
>> +struct ref_store_init_options {
>> +	/* The kind of operations that the ref_store is allowed to perform. */
>> +	unsigned int access_flags;
>> +
>> +	/*
>> +	 * Denotes under what conditions reflogs should be created when updating
>> +	 * references.
>> +	 */
>> +	enum log_refs_config log_all_ref_updates;
>> +};
>
> Nit: it might've made sense to split this up into two steps: the
> introduction of the struct, and then moving the config in there.
>
> Patrick
Yeah that might be better. I'll go ahead and do that.
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 7 of 68 in “refs: move some of the generic logic out of the backends”
  1. 0/8 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 20, 2026
  2. 1/8 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 20, 2026
  3. Patrick SteinhardtApr 22, 2026
  4. Karthik NayakApr 22, 2026
  5. 2/8 refs: extract out reflog config to generic layerKarthik Nayak, Apr 20, 2026
  6. Patrick SteinhardtApr 22, 2026
  7. Karthik NayakApr 22, 2026
  8. 3/8 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 20, 2026
  9. Patrick SteinhardtApr 22, 2026
  10. Karthik NayakApr 22, 2026
  11. 4/8 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 20, 2026
  12. Patrick SteinhardtApr 22, 2026
  13. Karthik NayakApr 22, 2026
  14. 5/8 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 20, 2026
  15. Patrick SteinhardtApr 22, 2026
  16. Karthik NayakApr 22, 2026
  17. 6/8 refs: move object parsing to the generic layerKarthik Nayak, Apr 20, 2026
  18. Patrick SteinhardtApr 22, 2026
  19. Karthik NayakApr 22, 2026
  20. 8/8 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 20, 2026
  21. 7/8 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 20, 2026
  22. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 23, 2026
  23. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 23, 2026
  24. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 23, 2026
  25. Patrick SteinhardtApr 23, 2026
  26. Karthik NayakApr 24, 2026
  27. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 23, 2026
  28. Patrick SteinhardtApr 23, 2026
  29. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 23, 2026
  30. Toon ClaesApr 24, 2026
  31. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 23, 2026
  32. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 23, 2026
  33. Patrick SteinhardtApr 23, 2026
  34. Karthik NayakApr 24, 2026
  35. Toon ClaesApr 24, 2026
  36. Karthik NayakApr 27, 2026
  37. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 23, 2026
  38. Toon ClaesApr 24, 2026
  39. Karthik NayakApr 27, 2026
  40. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 23, 2026
  41. Toon ClaesApr 24, 2026
  42. Karthik NayakApr 27, 2026
  43. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 23, 2026
  44. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 27, 2026
  45. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 27, 2026
  46. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 27, 2026
  47. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 27, 2026
  48. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 27, 2026
  49. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 27, 2026
  50. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 27, 2026
  51. Toon ClaesApr 29, 2026
  52. Karthik NayakApr 30, 2026
  53. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 27, 2026
  54. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 27, 2026
  55. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 27, 2026
  56. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, May 4, 2026
  57. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, May 4, 2026
  58. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, May 4, 2026
  59. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, May 4, 2026
  60. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, May 4, 2026
  61. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, May 4, 2026
  62. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, May 4, 2026
  63. Patrick SteinhardtMay 5, 2026
  64. Karthik NayakMay 5, 2026
  65. Toon ClaesMay 6, 2026
  66. 7/9 refs: move object parsing to the generic layerKarthik Nayak, May 4, 2026
  67. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, May 4, 2026
  68. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, May 4, 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.