refs: extract out reflog config to generic layer

The reference backends need to know when to create reflog entries, this is dictated by the 'core.logallrefupdates' config. Instead of relying on 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. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed May 4, 2026 at 19:44 UTC cc42c88945753363d67d130c79640e3c682e1334
4 files changed +9 -2
refs.c
+1
@@ -2297,6 +2297,7 @@ static struct ref_store *ref_store_init(struct repository *repo,
2297 struct ref_store *refs;
2298 struct ref_store_init_options opts = {
2299 .access_flags = flags,
2300 + .log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo),
2301 };
2302
2303 be = find_ref_storage_backend(format);
refs/files-backend.c
+1 -1
@@ -125,7 +125,7 @@ static struct ref_store *files_ref_store_init(struct repository *repo,
125 refs->packed_ref_store =
126 packed_ref_store_init(repo, NULL, refs->gitcommondir, opts);
127 refs->store_flags = opts->access_flags;
128 - refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
128 + refs->log_all_ref_updates = opts->log_all_ref_updates;
129
130 repo_config_get_bool(repo, "core.prefersymlinkrefs", &refs->prefer_symlink_refs);
131
refs/refs-internal.h
+6
@@ -392,6 +392,12 @@ struct ref_store;
392 struct ref_store_init_options {
393 /* The kind of operations that the ref_store is allowed to perform. */
394 unsigned int access_flags;
395 +
396 + /*
397 + * Denotes under what conditions reflogs should be created when updating
398 + * references.
399 + */
400 + enum log_refs_config log_all_ref_updates;
401 };
402
403 /*
refs/reftable-backend.c
+1 -1
@@ -386,7 +386,7 @@ static struct ref_store *reftable_be_init(struct repository *repo,
386
387 base_ref_store_init(&refs->base, repo, refdir.buf, &refs_be_reftable);
388 strmap_init(&refs->worktree_backends);
389 - refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
389 + refs->log_all_ref_updates = opts->log_all_ref_updates;
390 refs->store_flags = opts->access_flags;
391
392 switch (repo->hash_algo->format_id) {