@matheusbsbs / matheus-bagliano / commits / a53f2ec617
Fork 0

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>

Junio C Hamano committed Apr 12, 2008 at 18:33 UTC a53f2ec617ba36a67bf8794d28d666d45ce374a6
2 files changed +10 -1
cache.h
+1
@@ -692,6 +692,7 @@ extern int git_parse_long(const char *, long *);
692 extern int git_parse_ulong(const char *, unsigned long *);
693 extern int git_config_int(const char *, const char *);
694 extern unsigned long git_config_ulong(const char *, const char *);
695 +extern int git_config_bool_or_int(const char *, const char *, int *);
696 extern int git_config_bool(const char *, const char *);
697 extern int git_config_string(const char **, const char *, const char *);
698 extern int git_config_set(const char *, const char *);
config.c
+9 -1
@@ -303,8 +303,9 @@ unsigned long git_config_ulong(const char *name, const char *value)
303 return ret;
304 }
305
306 -int git_config_bool(const char *name, const char *value)
306 +int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
307 {
308 + *is_bool = 1;
309 if (!value)
310 return 1;
311 if (!*value)
@@ -313,9 +314,16 @@ int git_config_bool(const char *name, const char *value)
314 return 1;
315 if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
316 return 0;
317 + *is_bool = 0;
318 return git_config_int(name, value) != 0;
319 }
320
321 +int git_config_bool(const char *name, const char *value)
322 +{
323 + int discard;
324 + return git_config_bool_or_int(name, value, &discard);
325 +}
326 +
327 int git_config_string(const char **dest, const char *var, const char *value)
328 {
329 if (!value)