From eafb126456b235c5281e3ae50bfd526552ce12d3 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 12 Sep 2024 13:30:18 +0200 Subject: environment: stop storing "core.logAllRefUpdates" globally The value of "core.logAllRefUpdates" is being stored in the global variable `log_all_ref_updates`. This design is somewhat aged nowadays, where it is entirely possible to access multiple repositories in the same process which all have different values for this setting. So using a single global variable to track it is plain wrong. Remove the global variable. Instead, we now provide a new function part of the repo-settings subsystem that parses the value for a specific repository. While that may require us to read the value multiple times, we work around this by reading it once when the ref backends are set up and caching the value there. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- repo-settings.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'repo-settings.c') diff --git a/repo-settings.c b/repo-settings.c index 3a76ba276c..1322fd2f97 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -124,3 +124,19 @@ void prepare_repo_settings(struct repository *r) */ r->settings.command_requires_full_index = 1; } + +enum log_refs_config repo_settings_get_log_all_ref_updates(struct repository *repo) +{ + const char *value; + + if (!repo_config_get_string_tmp(repo, "core.logallrefupdates", &value)) { + if (value && !strcasecmp(value, "always")) + return LOG_REFS_ALWAYS; + else if (git_config_bool("core.logallrefupdates", value)) + return LOG_REFS_NORMAL; + else + return LOG_REFS_NONE; + } + + return LOG_REFS_UNSET; +} -- cgit 1.2.3-korg