Skip to content

Commit

Permalink
Add config_error_nonbool() helper function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Feb 11, 2008
1 parent c5e5a2c commit 40ea4ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
9 changes: 9 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 40ea4ed

Please sign in to comment.