@matheusbsbs / matheus-bagliano / commits / 40ea4ed903
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Feb 11, 2008 at 10:41 UTC 40ea4ed9032a80c9dba706d6030bd11b08c35f4d
2 files changed +10
cache.h
+1
@@ -589,6 +589,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int
589 extern int git_config_rename_section(const char *, const char *);
590 extern const char *git_etc_gitconfig(void);
591 extern int check_repository_format_version(const char *var, const char *value);
592 +extern int config_error_nonbool(const char *);
593
594 #define MAX_GITNAME (1000)
595 extern char git_default_email[MAX_GITNAME];
config.c
+9
@@ -1079,3 +1079,12 @@ int git_config_rename_section(const char *old_name, const char *new_name)
1079 free(config_filename);
1080 return ret;
1081 }
1082 +
1083 +/*
1084 + * Call this to report error for your variable that should not
1085 + * get a boolean value (i.e. "[my] var" means "true").
1086 + */
1087 +int config_error_nonbool(const char *var)
1088 +{
1089 + return error("Missing value for '%s'", var);
1090 +}