@matheusbsbs / matheus-bagliano / commits / a5cb4204b6
Fork 0

config: make scope_name non-static and rename it

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>

Matthew Rogers committed Feb 10, 2020 at 00:30 UTC a5cb4204b63b57e99ae3a44f23a7945f146fe078
3 files changed +18 -16
config.c
+16
@@ -3297,6 +3297,22 @@ const char *current_config_origin_type(void)
3297 }
3298 }
3299
3300 +const char *config_scope_name(enum config_scope scope)
3301 +{
3302 + switch (scope) {
3303 + case CONFIG_SCOPE_SYSTEM:
3304 + return "system";
3305 + case CONFIG_SCOPE_GLOBAL:
3306 + return "global";
3307 + case CONFIG_SCOPE_REPO:
3308 + return "repo";
3309 + case CONFIG_SCOPE_CMDLINE:
3310 + return "cmdline";
3311 + default:
3312 + return "unknown";
3313 + }
3314 +}
3315 +
3316 const char *current_config_name(void)
3317 {
3318 const char *name;
config.h
+1
@@ -301,6 +301,7 @@ enum config_scope {
301 CONFIG_SCOPE_REPO,
302 CONFIG_SCOPE_CMDLINE,
303 };
304 +const char *config_scope_name(enum config_scope scope);
305
306 enum config_scope current_config_scope(void);
307 const char *current_config_origin_type(void);
t/helper/test-config.c
+1 -16
@@ -37,21 +37,6 @@
37 *
38 */
39
40 -static const char *scope_name(enum config_scope scope)
41 -{
42 - switch (scope) {
43 - case CONFIG_SCOPE_SYSTEM:
44 - return "system";
45 - case CONFIG_SCOPE_GLOBAL:
46 - return "global";
47 - case CONFIG_SCOPE_REPO:
48 - return "repo";
49 - case CONFIG_SCOPE_CMDLINE:
50 - return "cmdline";
51 - default:
52 - return "unknown";
53 - }
54 -}
40 static int iterate_cb(const char *var, const char *value, void *data)
41 {
42 static int nr;
@@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
48 printf("value=%s\n", value ? value : "(null)");
49 printf("origin=%s\n", current_config_origin_type());
50 printf("name=%s\n", current_config_name());
66 - printf("scope=%s\n", scope_name(current_config_scope()));
51 + printf("scope=%s\n", config_scope_name(current_config_scope()));
52
53 return 0;
54 }