]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: extract out reflog config to generic layer
authorKarthik Nayak <karthik.188@gmail.com>
Mon, 4 May 2026 17:44:07 +0000 (19:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 May 2026 07:34:07 +0000 (16:34 +0900)
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>
refs.c
refs/files-backend.c
refs/refs-internal.h
refs/reftable-backend.c

diff --git a/refs.c b/refs.c
index 8992dd6ae865dda1106c3541a0b7ac17f5c954a8..6b506aeea30bae9dad537f1f7f85507c7292495b 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2297,6 +2297,7 @@ 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),
        };
 
        be = find_ref_storage_backend(format);
index 72afe62cee59670cee39c0de8902f3b0dc893227..4b2faf477727b48878bac4c14cc835f70d61a09b 100644 (file)
@@ -125,7 +125,7 @@ static struct ref_store *files_ref_store_init(struct repository *repo,
        refs->packed_ref_store =
                packed_ref_store_init(repo, NULL, refs->gitcommondir, opts);
        refs->store_flags = opts->access_flags;
-       refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
+       refs->log_all_ref_updates = opts->log_all_ref_updates;
 
        repo_config_get_bool(repo, "core.prefersymlinkrefs", &refs->prefer_symlink_refs);
 
index f49b3807bf3382a3afa8e1c717b35ffbbb5db85c..d103387ebf1e921d1242cbef7bd5a66eb05d98c3 100644 (file)
@@ -392,6 +392,12 @@ struct ref_store;
 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;
 };
 
 /*
index ad4ee2627c441877aa5bb89359da433e5cbb6f6a..93374d25c24d2120d79153671179d11343c8aab5 100644 (file)
@@ -386,7 +386,7 @@ static struct ref_store *reftable_be_init(struct repository *repo,
 
        base_ref_store_init(&refs->base, repo, refdir.buf, &refs_be_reftable);
        strmap_init(&refs->worktree_backends);
-       refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
+       refs->log_all_ref_updates = opts->log_all_ref_updates;
        refs->store_flags = opts->access_flags;
 
        switch (repo->hash_algo->format_id) {