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>
This commit is contained in:

committed by
Junio C Hamano

parent
b411ed60c7
commit
6f3fbed8ed
6
path.h
6
path.h
@ -52,14 +52,14 @@ const char *repo_common_path_replace(const struct repository *repo,
|
||||
* For an exhaustive list of the adjustments made look at `common_list` and
|
||||
* `adjust_git_path` in path.c.
|
||||
*/
|
||||
char *repo_git_path(const struct repository *repo,
|
||||
char *repo_git_path(struct repository *repo,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 2, 3)));
|
||||
const char *repo_git_path_append(const struct repository *repo,
|
||||
const char *repo_git_path_append(struct repository *repo,
|
||||
struct strbuf *sb,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
const char *repo_git_path_replace(const struct repository *repo,
|
||||
const char *repo_git_path_replace(struct repository *repo,
|
||||
struct strbuf *sb,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
|
Reference in New Issue
Block a user