Skip to content

Commit 9a549d4

Browse files
dborowitzgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87c0d08 commit 9a549d4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,7 @@ extern int git_config_with_options(config_fn_t fn, void *,
13751375
int respect_includes);
13761376
extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
13771377
extern int git_parse_ulong(const char *, unsigned long *);
1378+
extern int git_parse_maybe_bool(const char *);
13781379
extern int git_config_int(const char *, const char *);
13791380
extern int64_t git_config_int64(const char *, const char *);
13801381
extern unsigned long git_config_ulong(const char *, const char *);

config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
618618
return ret;
619619
}
620620

621-
static int git_config_maybe_bool_text(const char *name, const char *value)
621+
int git_parse_maybe_bool(const char *value)
622622
{
623623
if (!value)
624624
return 1;
@@ -637,7 +637,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
637637

638638
int git_config_maybe_bool(const char *name, const char *value)
639639
{
640-
int v = git_config_maybe_bool_text(name, value);
640+
int v = git_parse_maybe_bool(value);
641641
if (0 <= v)
642642
return v;
643643
if (git_parse_int(value, &v))
@@ -647,7 +647,7 @@ int git_config_maybe_bool(const char *name, const char *value)
647647

648648
int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
649649
{
650-
int v = git_config_maybe_bool_text(name, value);
650+
int v = git_parse_maybe_bool(value);
651651
if (0 <= v) {
652652
*is_bool = 1;
653653
return v;

0 commit comments

Comments
 (0)