config.c: rename git_config_maybe_bool_text and export it as git_parse_maybe_bool
This helper function does not complain about the config variable but just silently reports failure to the caller. It is useful for callers that need to parse any string that could be boolean or other string (e.g. tristate yes/no/auto). Signed-off-by: Dave Borowitz <dborowitz@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dave Borowitz committed
Aug 19, 2015 at 11:26 UTC
9a549d4397a624a819e881137c519d0ca61fe7e8
2 files changed
+4
-3
cache.h
+1
@@ -1375,6 +1375,7 @@ extern int git_config_with_options(config_fn_t fn, void *,
1375
int respect_includes);
1376
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
1377
extern int git_parse_ulong(const char *, unsigned long *);
1378
+extern int git_parse_maybe_bool(const char *);
1379
extern int git_config_int(const char *, const char *);
1380
extern int64_t git_config_int64(const char *, const char *);
1381
extern unsigned long git_config_ulong(const char *, const char *);
config.c
+3
-3
@@ -618,7 +618,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
618
return ret;
619
}
620
621
-static int git_config_maybe_bool_text(const char *name, const char *value)
621
+int git_parse_maybe_bool(const char *value)
622
{
623
if (!value)
624
return 1;
@@ -637,7 +637,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
637
638
int git_config_maybe_bool(const char *name, const char *value)
639
{
640
- int v = git_config_maybe_bool_text(name, value);
640
+ int v = git_parse_maybe_bool(value);
641
if (0 <= v)
642
return v;
643
if (git_parse_int(value, &v))
@@ -647,7 +647,7 @@ int git_config_maybe_bool(const char *name, const char *value)
647
648
int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
649
{
650
- int v = git_config_maybe_bool_text(name, value);
650
+ int v = git_parse_maybe_bool(value);
651
if (0 <= v) {
652
*is_bool = 1;
653
return v;