]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Add config_error_nonbool() helper function
authorJunio C Hamano <gitster@pobox.com>
Mon, 11 Feb 2008 18:41:18 +0000 (10:41 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Feb 2008 21:11:36 +0000 (13:11 -0800)
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 <gitster@pobox.com>
cache.h
config.c

diff --git a/cache.h b/cache.h
index 549f4bbac7242714283e58dd576460ca86015d52..6abcee437238ccc2b46e7d7d74f79db3a4b682a1 100644 (file)
--- 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];
index e799f40db74fd1f40849dcec21e997f165a52e35..03c94a27043681678ad6dd08df6de5c6b7cb4dc7 100644 (file)
--- 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);
+}