X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=config.c;h=64e41bea22466a81df5eda274bc97e3860d6cde6;hb=e2ab0227aab5cdcede3b39e4c95b118f09a71d29;hp=6963fbea43e6420f5f8dafc5b94fb5c27de6ffd2;hpb=b10b9184afc9e62140d307dcf2f5d7e625f78c79;p=~andy%2Fgit diff --git a/config.c b/config.c index 6963fbea4..64e41bea2 100644 --- a/config.c +++ b/config.c @@ -322,17 +322,30 @@ unsigned long git_config_ulong(const char *name, const char *value) return ret; } -int git_config_bool_or_int(const char *name, const char *value, int *is_bool) +int git_config_maybe_bool(const char *name, const char *value) { - *is_bool = 1; if (!value) return 1; if (!*value) return 0; - if (!strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "on")) + if (!strcasecmp(value, "true") + || !strcasecmp(value, "yes") + || !strcasecmp(value, "on")) return 1; - if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "off")) + if (!strcasecmp(value, "false") + || !strcasecmp(value, "no") + || !strcasecmp(value, "off")) return 0; + return -1; +} + +int git_config_bool_or_int(const char *name, const char *value, int *is_bool) +{ + int v = git_config_maybe_bool(name, value); + if (0 <= v) { + *is_bool = 1; + return v; + } *is_bool = 0; return git_config_int(name, value); }