aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-04-12 18:33:31 -0700
committerJunio C Hamano <gitster@pobox.com>2008-04-12 18:38:40 -0700
commita53f2ec617ba36a67bf8794d28d666d45ce374a6 (patch)
tree7e64d68fe0b4363e3986b76741b30f60532a1b5b /config.c
parent4cdda2b895dfb6ba084e3952cbf4274a6a2e0338 (diff)
downloadgit-a53f2ec617ba36a67bf8794d28d666d45ce374a6.tar.gz
git-a53f2ec617ba36a67bf8794d28d666d45ce374a6.tar.xz
git_config_bool_or_int()
This new function can be used by config parsers to tell if a variable is simply set, set to 1, or set to "true". Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/config.c b/config.c
index 062449459..5ea18efae 100644
--- a/config.c
+++ b/config.c
@@ -303,8 +303,9 @@ unsigned long git_config_ulong(const char *name, const char *value)
return ret;
}
-int git_config_bool(const char *name, const char *value)
+int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
{
+ *is_bool = 1;
if (!value)
return 1;
if (!*value)
@@ -313,9 +314,16 @@ int git_config_bool(const char *name, const char *value)
return 1;
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
return 0;
+ *is_bool = 0;
return git_config_int(name, value) != 0;
}
+int git_config_bool(const char *name, const char *value)
+{
+ int discard;
+ return git_config_bool_or_int(name, value, &discard);
+}
+
int git_config_string(const char **dest, const char *var, const char *value)
{
if (!value)