refs: stop modifying global log_all_ref_updates variable

In refs-related code we modify the global `log_all_ref_updates`
variable, which is done because `should_autocreate_reflog()` does not
accept passing an `enum log_refs_config` but instead accesses the global
variable. Adapt its interface such that the value is provided by the
caller, which allows us to compute the proper value locally without
having to modify global state.

This change requires us to move the enum to "repo-settings.h", or
otherwise we get compilation errors due to include cycles. We're about
to fully move this setting into the repo-settings subsystem anyway, so
this is fine.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-09-12 13:30:13 +02:00
committed by Junio C Hamano
parent 118fd1a26d
commit 9a20b889e8
7 changed files with 36 additions and 26 deletions

4
refs.h
View File

@@ -3,6 +3,7 @@
#include "commit.h"
#include "repository.h"
#include "repo-settings.h"
struct fsck_options;
struct object_id;
@@ -111,7 +112,8 @@ int refs_verify_refname_available(struct ref_store *refs,
int refs_ref_exists(struct ref_store *refs, const char *refname);
int should_autocreate_reflog(const char *refname);
int should_autocreate_reflog(enum log_refs_config log_all_ref_updates,
const char *refname);
int is_branch(const char *refname);