From b92266b79c7bb741e3600e9dc206b693d8062fa9 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 12 Sep 2024 13:29:45 +0200 Subject: config: make dependency on repo in `read_early_config()` explicit The `read_early_config()` function can be used to read configuration where a repository has not yet been set up. As such, it is optional whether or not `the_repository` has already been initialized. If it was initialized we use its commondir and gitdir. If not, the function will try to detect the Git directories by itself and, if found, also parse their config files. This means that we implicitly rely on `the_repository`. Make this dependency explicit by passing a `struct repository`. This allows us to again drop the `USE_THE_REPOSITORY_VARIABLE` define in "config.c". Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- alias.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'alias.c') diff --git a/alias.c b/alias.c index 4daafd9bda..1a1a141a0a 100644 --- a/alias.c +++ b/alias.c @@ -1,3 +1,5 @@ +#define USE_THE_REPOSITORY_VARIABLE + #include "git-compat-util.h" #include "alias.h" #include "config.h" @@ -37,7 +39,7 @@ char *alias_lookup(const char *alias) { struct config_alias_data data = { alias, NULL }; - read_early_config(config_alias_cb, &data); + read_early_config(the_repository, config_alias_cb, &data); return data.v; } @@ -46,7 +48,7 @@ void list_aliases(struct string_list *list) { struct config_alias_data data = { NULL, NULL, list }; - read_early_config(config_alias_cb, &data); + read_early_config(the_repository, config_alias_cb, &data); } void quote_cmdline(struct strbuf *buf, const char **argv) -- cgit v1.3-5-g9baa