summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorMatthew Rogers <mattr94@gmail.com>2020-02-10 00:30:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-10 18:32:20 (GMT)
commit6dc905d97431d683b418978819629a2626555b2e (patch)
treee0c0ccd015ec1f1471b40ed42d0fb8e562f8eb1f /config.c
parenta5cb4204b63b57e99ae3a44f23a7945f146fe078 (diff)
downloadgit-6dc905d97431d683b418978819629a2626555b2e.zip
git-6dc905d97431d683b418978819629a2626555b2e.tar.gz
git-6dc905d97431d683b418978819629a2626555b2e.tar.bz2
config: split repo scope to local and worktree
Previously when iterating through git config variables, worktree config and local config were both considered "CONFIG_SCOPE_REPO". This was never a problem before as no one had needed to differentiate between the two cases, but future functionality may care whether or not the config options come from a worktree or from the repository's actual local config file. For example, the planned feature to add a '--show-scope' to config to allow a user to see which scope listed config options come from would confuse users if it just printed 'repo' rather than 'local' or 'worktree' as the documentation would lead them to expect. As well as the additional benefit of making the implementation look more like how the documentation describes the interface. To accomplish this we split out what was previously considered repo scope to be local and worktree. The clients of 'current_config_scope()' who cared about CONFIG_SCOPE_REPO are also modified to similarly care about CONFIG_SCOPE_WORKTREE and CONFIG_SCOPE_LOCAL to preserve previous behavior. Signed-off-by: Matthew Rogers <mattr94@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/config.c b/config.c
index a922b13..f68eec7 100644
--- a/config.c
+++ b/config.c
@@ -1724,15 +1724,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))
@@ -3304,8 +3301,10 @@ const char *config_scope_name(enum config_scope scope)
return "system";
case CONFIG_SCOPE_GLOBAL:
return "global";
- case CONFIG_SCOPE_REPO:
- return "repo";
+ case CONFIG_SCOPE_LOCAL:
+ return "local";
+ case CONFIG_SCOPE_WORKTREE:
+ return "worktree";
case CONFIG_SCOPE_CMDLINE:
return "cmdline";
default: