@matheusbsbs / matheus-bagliano / commits / 9a83d088ee
Fork 0

submodule-config: add subomdule config scope

Before the changes to teach git_config_source to remember scope information submodule-config.c never needed to consider the question of config scope. Even though zeroing out git_config_source is still correct and preserved the previous behavior of setting the scope to CONFIG_SCOPE_UNKNOWN, it's better to be explicit about such situations by explicitly setting the scope. As none of the current config_scope enumerations make sense we create CONFIG_SCOPE_SUBMODULE to describe the situation. Signed-off-by: Matthew Rogers <mattr94@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthew Rogers committed Feb 10, 2020 at 00:30 UTC 9a83d088ee00dcdab171b2020ab334e369437a33
3 files changed +6 -1
config.c
+2
@@ -3311,6 +3311,8 @@ const char *config_scope_name(enum config_scope scope)
3311 return "worktree";
3312 case CONFIG_SCOPE_COMMAND:
3313 return "command";
3314 + case CONFIG_SCOPE_SUBMODULE:
3315 + return "submodule";
3316 default:
3317 return "unknown";
3318 }
config.h
+1
@@ -42,6 +42,7 @@ enum config_scope {
42 CONFIG_SCOPE_LOCAL,
43 CONFIG_SCOPE_WORKTREE,
44 CONFIG_SCOPE_COMMAND,
45 + CONFIG_SCOPE_SUBMODULE,
46 };
47 const char *config_scope_name(enum config_scope scope);
48
submodule-config.c
+3 -1
@@ -635,7 +635,9 @@ static void submodule_cache_check_init(struct repository *repo)
635 static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
636 {
637 if (repo->worktree) {
638 - struct git_config_source config_source = { 0 };
638 + struct git_config_source config_source = {
639 + 0, .scope = CONFIG_SCOPE_SUBMODULE
640 + };
641 const struct config_options opts = { 0 };
642 struct object_id oid;
643 char *file;