Skip to content

Commit a5cb420

Browse files
ROGERSM94gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 417be08 commit a5cb420

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

config.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,6 +3297,22 @@ const char *current_config_origin_type(void)
32973297
}
32983298
}
32993299

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+
33003316
const char *current_config_name(void)
33013317
{
33023318
const char *name;

config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ enum config_scope {
301301
CONFIG_SCOPE_REPO,
302302
CONFIG_SCOPE_CMDLINE,
303303
};
304+
const char *config_scope_name(enum config_scope scope);
304305

305306
enum config_scope current_config_scope(void);
306307
const char *current_config_origin_type(void);

t/helper/test-config.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@
3737
*
3838
*/
3939

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-
}
5540
static int iterate_cb(const char *var, const char *value, void *data)
5641
{
5742
static int nr;
@@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
6348
printf("value=%s\n", value ? value : "(null)");
6449
printf("origin=%s\n", current_config_origin_type());
6550
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()));
6752

6853
return 0;
6954
}

0 commit comments

Comments
 (0)