aboutsummaryrefslogtreecommitdiffstats
path: root/repo-settings.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-07 12:03:39 +0100
committerJunio C Hamano <gitster@pobox.com>2025-02-28 13:54:11 -0800
commit6f3fbed8eda577703426d77dacc71ce0ba46634e (patch)
tree9203a2881677e2988b315f1e8aed4e84ac13eac0 /repo-settings.h
parentrepo-settings: introduce function to clear struct (diff)
downloadgit-6f3fbed8eda577703426d77dacc71ce0ba46634e.tar.gz
git-6f3fbed8eda577703426d77dacc71ce0ba46634e.zip
environment: move access to "core.hooksPath" into repo settings
The "core.hooksPath" setting is stored in a global variable and populated via the `git_default_core_config`. This may cause issues in the case where one is handling multiple different repositories in a single process with different values for that config key, as we may or may not see the correct value in that case. Furthermore, global state blocks our path towards libification. Refactor the code so that we instead store the value in `struct repo_settings`. The value is computed as-needed and cached. The result should be functionally the same as there aren't ever any code paths where we'd execute hooks outside the context of a repository. Note that this requires us to change the passed-in repository in the `repo_git_path()` family of functions to be non-constant, as we call `adjust_git_path()` there. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repo-settings.h')
-rw-r--r--repo-settings.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/repo-settings.h b/repo-settings.h
index c4f7e3bd8a..0cef970443 100644
--- a/repo-settings.h
+++ b/repo-settings.h
@@ -61,6 +61,8 @@ struct repo_settings {
size_t delta_base_cache_limit;
size_t packed_git_window_size;
size_t packed_git_limit;
+
+ char *hooks_path;
};
#define REPO_SETTINGS_INIT { \
.index_version = -1, \
@@ -79,5 +81,7 @@ void repo_settings_clear(struct repository *r);
enum log_refs_config repo_settings_get_log_all_ref_updates(struct repository *repo);
/* Read the value for "core.warnAmbiguousRefs". */
int repo_settings_get_warn_ambiguous_refs(struct repository *repo);
+/* Read the value for "core.hooksPath". */
+const char *repo_settings_get_hooks_path(struct repository *repo);
#endif /* REPO_SETTINGS_H */