summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/config.c b/config.c
index b386c0c628..79b0a56af8 100644
--- a/config.c
+++ b/config.c
@@ -1702,6 +1702,7 @@ static int do_git_config_sequence(const struct config_options *opts,
char *xdg_config = xdg_config_home("config");
char *user_config = expand_user_path("~/.gitconfig", 0);
char *repo_config;
+ enum config_scope prev_parsing_scope = current_parsing_scope;
if (opts->commondir)
repo_config = mkpathdup("%s/config", opts->commondir);
@@ -1724,15 +1725,12 @@ static int do_git_config_sequence(const struct config_options *opts,
if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK))
ret += git_config_from_file(fn, user_config, data);
- current_parsing_scope = CONFIG_SCOPE_REPO;
+ current_parsing_scope = CONFIG_SCOPE_LOCAL;
if (!opts->ignore_repo && repo_config &&
!access_or_die(repo_config, R_OK, 0))
ret += git_config_from_file(fn, repo_config, data);
- /*
- * Note: this should have a new scope, CONFIG_SCOPE_WORKTREE.
- * But let's not complicate things before it's actually needed.
- */
+ current_parsing_scope = CONFIG_SCOPE_WORKTREE;
if (!opts->ignore_worktree && repository_format_worktree_config) {
char *path = git_pathdup("config.worktree");
if (!access_or_die(path, R_OK, 0))
@@ -1740,11 +1738,11 @@ static int do_git_config_sequence(const struct config_options *opts,
free(path);
}
- current_parsing_scope = CONFIG_SCOPE_CMDLINE;
+ current_parsing_scope = CONFIG_SCOPE_COMMAND;
if (!opts->ignore_cmdline && git_config_from_parameters(fn, data) < 0)
die(_("unable to parse command-line config"));
- current_parsing_scope = CONFIG_SCOPE_UNKNOWN;
+ current_parsing_scope = prev_parsing_scope;
free(xdg_config);
free(user_config);
free(repo_config);
@@ -1765,6 +1763,9 @@ int config_with_options(config_fn_t fn, void *data,
data = &inc;
}
+ if (config_source)
+ current_parsing_scope = config_source->scope;
+
/*
* If we have a specific filename, use it. Otherwise, follow the
* regular lookup sequence.
@@ -3297,6 +3298,26 @@ const char *current_config_origin_type(void)
}
}
+const char *config_scope_name(enum config_scope scope)
+{
+ switch (scope) {
+ case CONFIG_SCOPE_SYSTEM:
+ return "system";
+ case CONFIG_SCOPE_GLOBAL:
+ return "global";
+ case CONFIG_SCOPE_LOCAL:
+ return "local";
+ case CONFIG_SCOPE_WORKTREE:
+ return "worktree";
+ case CONFIG_SCOPE_COMMAND:
+ return "command";
+ case CONFIG_SCOPE_SUBMODULE:
+ return "submodule";
+ default:
+ return "unknown";
+ }
+}
+
const char *current_config_name(void)
{
const char *name;