1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 19:26:38 +02:00

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>
This commit is contained in:
Dave Borowitz 2015-08-19 11:26:44 -04:00 committed by Junio C Hamano
parent 87c0d08b3d
commit 9a549d4397
2 changed files with 4 additions and 3 deletions

View File

@ -1375,6 +1375,7 @@ extern int git_config_with_options(config_fn_t fn, void *,
int respect_includes);
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_parse_maybe_bool(const char *);
extern int git_config_int(const char *, const char *);
extern int64_t git_config_int64(const char *, const char *);
extern unsigned long git_config_ulong(const char *, const char *);

View File

@ -618,7 +618,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
return ret;
}
static int git_config_maybe_bool_text(const char *name, const char *value)
int git_parse_maybe_bool(const char *value)
{
if (!value)
return 1;
@ -637,7 +637,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
int git_config_maybe_bool(const char *name, const char *value)
{
int v = git_config_maybe_bool_text(name, value);
int v = git_parse_maybe_bool(value);
if (0 <= v)
return v;
if (git_parse_int(value, &v))
@ -647,7 +647,7 @@ int git_config_maybe_bool(const char *name, const char *value)
int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
{
int v = git_config_maybe_bool_text(name, value);
int v = git_parse_maybe_bool(value);
if (0 <= v) {
*is_bool = 1;
return v;