Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlen Choo <chooglen@google.com>2022-10-13 20:43:47 +0300
committerJunio C Hamano <gitster@pobox.com>2022-10-13 21:39:46 +0300
commitecec57b3c9731cf81cd1b9d515334168c2c68f5b (patch)
treedc912af8991cc432622edb77e6a150f67cf819e9 /config.c
parent776f184893d2861a729aa4b91d69931036e03e4b (diff)
config: respect includes in protected config
Protected config is implemented by reading a fixed set of paths, which ignores config [include]-s. Replace this implementation with a call to config_with_options(), which handles [include]-s and saves us from duplicating the logic of 1) identifying which paths to read and 2) reading command line config. As a result, git_configset_add_parameters() is unused, so remove it. It was introduced alongside protected config in 5b3c650777 (config: learn `git_protected_config()`, 2022-07-14) as a way to handle command line config. Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/config.c b/config.c
index e8ebef77d5..be0e789ccf 100644
--- a/config.c
+++ b/config.c
@@ -2391,11 +2391,6 @@ int git_configset_add_file(struct config_set *cs, const char *filename)
return git_config_from_file(config_set_callback, filename, cs);
}
-int git_configset_add_parameters(struct config_set *cs)
-{
- return git_config_from_parameters(config_set_callback, cs);
-}
-
int git_configset_get_value(struct config_set *cs, const char *key, const char **value)
{
const struct string_list *values = NULL;
@@ -2640,24 +2635,15 @@ int repo_config_get_pathname(struct repository *repo,
/* Read values into protected_config. */
static void read_protected_config(void)
{
- char *xdg_config = NULL, *user_config = NULL, *system_config = NULL;
-
+ struct config_options opts = {
+ .respect_includes = 1,
+ .ignore_repo = 1,
+ .ignore_worktree = 1,
+ .system_gently = 1,
+ };
git_configset_init(&protected_config);
-
- system_config = git_system_config();
- git_global_config(&user_config, &xdg_config);
-
- if (system_config)
- git_configset_add_file(&protected_config, system_config);
- if (xdg_config)
- git_configset_add_file(&protected_config, xdg_config);
- if (user_config)
- git_configset_add_file(&protected_config, user_config);
- git_configset_add_parameters(&protected_config);
-
- free(system_config);
- free(xdg_config);
- free(user_config);
+ config_with_options(config_set_callback, &protected_config,
+ NULL, &opts);
}
void git_protected_config(config_fn_t fn, void *data)