From 9b6b06c159e0a389aaafbce91dd85bb5244ac5ad Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Fri, 26 May 2023 01:32:59 +0000 Subject: config: pass 'repo' directly to 'config_with_options()' Add a 'struct repository' argument to 'config_with_options()' and remove the 'repo' field from 'struct git_config_source'. A 'struct repository' instance was originally added to the config source in e3e8bf046e9 (submodule-config: pass repo upon blob config read, 2021-08-16) to improve how submodule blob config content was accessed. At the time, this was the only use for a 'repository' instance, so it was naturally added only where it was needed: to 'struct git_config_source'. However, in upcoming patches, 'config_with_options()' will need the repository instance to access extension information (regardless of whether a 'config_source' exists). To make the 'struct repository' instance more easily accessible, move it into the function's arguments. Update all callers of 'config_with_options()' to pass the appropriate 'repo' value: * in 'builtin/config.c', use 'the_repository' * in 'submodule--config.c', use the 'repo' arg in 'config_from_gitmodules()' * in 'read_[very_]early_config()' & 'read_protected_config()', set 'repo' to NULL (repository instances aren't available there) * in 'populate_remote_urls()', use the repo instance that has been added to the 'struct config_include_data' * in 'repo_read_config()', use the given 'repo' arg Finally, note that this patch eliminates the fallback to 'the_repository' that previously existed for the 'config_source' repo instance if it was NULL. The fallback is no longer necessary, as the 'repo' is set explicitly in all cases where it is needed. Signed-off-by: Victoria Dye Signed-off-by: Junio C Hamano --- config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index 247b572b37..d1c5577589 100644 --- a/config.h +++ b/config.h @@ -3,6 +3,7 @@ #include "hashmap.h" #include "string-list.h" +#include "repository.h" /** @@ -49,8 +50,6 @@ const char *config_scope_name(enum config_scope scope); struct git_config_source { unsigned int use_stdin:1; const char *file; - /* The repository if blob is not NULL; leave blank for the_repository */ - struct repository *repo; const char *blob; enum config_scope scope; }; @@ -196,6 +195,7 @@ void git_config(config_fn_t fn, void *); */ int config_with_options(config_fn_t fn, void *, struct git_config_source *config_source, + struct repository *repo, const struct config_options *opts); /** -- cgit v1.2.3