]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule-config: add subomdule config scope
authorMatthew Rogers <mattr94@gmail.com>
Mon, 10 Feb 2020 00:30:58 +0000 (00:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Feb 2020 18:49:12 +0000 (10:49 -0800)
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>
config.c
config.h
submodule-config.c

index 9b6afca21016abf36e70633ea76430ee26d3d4a9..18a6bdd9ffe587434ae5e7aea82d6ca2cde5c0d0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -3311,6 +3311,8 @@ const char *config_scope_name(enum config_scope scope)
                return "worktree";
        case CONFIG_SCOPE_COMMAND:
                return "command";
+       case CONFIG_SCOPE_SUBMODULE:
+               return "submodule";
        default:
                return "unknown";
        }
index 165cacb7daacdcc449d51d360a1d332d2791ba28..fe0addb0dc96cd1150c61c5028e0d41424153ee5 100644 (file)
--- a/config.h
+++ b/config.h
@@ -42,6 +42,7 @@ enum config_scope {
        CONFIG_SCOPE_LOCAL,
        CONFIG_SCOPE_WORKTREE,
        CONFIG_SCOPE_COMMAND,
+       CONFIG_SCOPE_SUBMODULE,
 };
 const char *config_scope_name(enum config_scope scope);
 
index 85064810b20adc7dc02e1d7a776b58437e9595c6..b8e97d8ae84a06c64c2bf6e707844ec19d9896d1 100644 (file)
@@ -635,7 +635,9 @@ static void submodule_cache_check_init(struct repository *repo)
 static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
 {
        if (repo->worktree) {
-               struct git_config_source config_source = { 0 };
+               struct git_config_source config_source = {
+                       0, .scope = CONFIG_SCOPE_SUBMODULE
+               };
                const struct config_options opts = { 0 };
                struct object_id oid;
                char *file;