]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: make scope_name non-static and rename it
authorMatthew Rogers <mattr94@gmail.com>
Mon, 10 Feb 2020 00:30:53 +0000 (00:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Feb 2020 18:32:18 +0000 (10:32 -0800)
To prepare for the upcoming --show-scope option, we require the ability
to convert a config_scope enum to a string.  As this was originally
implemented as a static function 'scope_name()' in
t/helper/test-config.c, we expose it via config.h and give it a less
ambiguous name 'config_scope_name()'

Signed-off-by: Matthew Rogers <mattr94@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
config.h
t/helper/test-config.c

index d75f88ca0ce31f1a9b6b3a8a2198c4f94a4196b5..a922b136e5514f07fccf42be95d8cd9db4bc7dfe 100644 (file)
--- a/config.c
+++ b/config.c
@@ -3297,6 +3297,22 @@ 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_REPO:
+               return "repo";
+       case CONFIG_SCOPE_CMDLINE:
+               return "cmdline";
+       default:
+               return "unknown";
+       }
+}
+
 const char *current_config_name(void)
 {
        const char *name;
index 91fd4c5e96ae79f48d32c511387fbf166224154a..c063f33ff6539c3bbddd6f692a8a4cbb20a5e640 100644 (file)
--- a/config.h
+++ b/config.h
@@ -301,6 +301,7 @@ enum config_scope {
        CONFIG_SCOPE_REPO,
        CONFIG_SCOPE_CMDLINE,
 };
+const char *config_scope_name(enum config_scope scope);
 
 enum config_scope current_config_scope(void);
 const char *current_config_origin_type(void);
index 214003d5b2f9bbe978d5aa4d9c9ab3f9b8a990da..1e3bc7c8f4a57e131bb40a2044d1cbbabe754211 100644 (file)
  *
  */
 
-static const char *scope_name(enum config_scope scope)
-{
-       switch (scope) {
-       case CONFIG_SCOPE_SYSTEM:
-               return "system";
-       case CONFIG_SCOPE_GLOBAL:
-               return "global";
-       case CONFIG_SCOPE_REPO:
-               return "repo";
-       case CONFIG_SCOPE_CMDLINE:
-               return "cmdline";
-       default:
-               return "unknown";
-       }
-}
 static int iterate_cb(const char *var, const char *value, void *data)
 {
        static int nr;
@@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
        printf("value=%s\n", value ? value : "(null)");
        printf("origin=%s\n", current_config_origin_type());
        printf("name=%s\n", current_config_name());
-       printf("scope=%s\n", scope_name(current_config_scope()));
+       printf("scope=%s\n", config_scope_name(current_config_scope()));
 
        return 0;
 }