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>
This commit is contained in:
parent
4cdda2b895
commit
a53f2ec617
1
cache.h
1
cache.h
@ -692,6 +692,7 @@ extern int git_parse_long(const char *, long *);
|
|||||||
extern int git_parse_ulong(const char *, unsigned long *);
|
extern int git_parse_ulong(const char *, unsigned long *);
|
||||||
extern int git_config_int(const char *, const char *);
|
extern int git_config_int(const char *, const char *);
|
||||||
extern unsigned long git_config_ulong(const char *, const char *);
|
extern unsigned long git_config_ulong(const char *, const char *);
|
||||||
|
extern int git_config_bool_or_int(const char *, const char *, int *);
|
||||||
extern int git_config_bool(const char *, const char *);
|
extern int git_config_bool(const char *, const char *);
|
||||||
extern int git_config_string(const char **, const char *, const char *);
|
extern int git_config_string(const char **, const char *, const char *);
|
||||||
extern int git_config_set(const char *, const char *);
|
extern int git_config_set(const char *, const char *);
|
||||||
|
10
config.c
10
config.c
@ -303,8 +303,9 @@ unsigned long git_config_ulong(const char *name, const char *value)
|
|||||||
return ret;
|
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)
|
if (!value)
|
||||||
return 1;
|
return 1;
|
||||||
if (!*value)
|
if (!*value)
|
||||||
@ -313,9 +314,16 @@ int git_config_bool(const char *name, const char *value)
|
|||||||
return 1;
|
return 1;
|
||||||
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
|
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
|
||||||
return 0;
|
return 0;
|
||||||
|
*is_bool = 0;
|
||||||
return git_config_int(name, value) != 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)
|
int git_config_string(const char **dest, const char *var, const char *value)
|
||||||
{
|
{
|
||||||
if (!value)
|
if (!value)
|
||||||
|
Loading…
Reference in New Issue
Block a user