From: Junio C Hamano Date: Mon, 11 Feb 2008 18:41:18 +0000 (-0800) Subject: Add config_error_nonbool() helper function X-Git-Tag: v1.5.4.2~49 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=40ea4ed9032a80c9dba706d6030bd11b08c35f4d;p=git.git Add config_error_nonbool() helper function This is used to report misconfigured configuration file that does not give any value to a non-boolean variable, e.g. [section] var It is perfectly fine to say it if the section.var is a boolean (it means true), but if a variable expects a string value it should be flagged as a configuration error. Signed-off-by: Junio C Hamano --- diff --git a/cache.h b/cache.h index 549f4bbac..6abcee437 100644 --- a/cache.h +++ b/cache.h @@ -589,6 +589,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int extern int git_config_rename_section(const char *, const char *); extern const char *git_etc_gitconfig(void); extern int check_repository_format_version(const char *var, const char *value); +extern int config_error_nonbool(const char *); #define MAX_GITNAME (1000) extern char git_default_email[MAX_GITNAME]; diff --git a/config.c b/config.c index e799f40db..03c94a270 100644 --- a/config.c +++ b/config.c @@ -1079,3 +1079,12 @@ int git_config_rename_section(const char *old_name, const char *new_name) free(config_filename); return ret; } + +/* + * Call this to report error for your variable that should not + * get a boolean value (i.e. "[my] var" means "true"). + */ +int config_error_nonbool(const char *var) +{ + return error("Missing value for '%s'", var); +}