Split up default "core" config parsing into helper routine
It makes the code a bit easier to read, and in theory a bit faster too (no need to compare all the different "core.*" strings against non-core config options). The config system really should get something of a complete overhaul, but in the absense of that, this at least improves on it a tiny bit. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e449f10580
commit
806e2ad7fe
42
config.c
42
config.c
@ -332,7 +332,7 @@ int git_config_string(const char **dest, const char *var, const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_default_config(const char *var, const char *value, void *dummy)
|
||||
static int git_default_core_config(const char *var, const char *value)
|
||||
{
|
||||
/* This needs a better name */
|
||||
if (!strcmp(var, "core.filemode")) {
|
||||
@ -444,6 +444,31 @@ int git_default_config(const char *var, const char *value, void *dummy)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.pager"))
|
||||
return git_config_string(&pager_program, var, value);
|
||||
|
||||
if (!strcmp(var, "core.editor"))
|
||||
return git_config_string(&editor_program, var, value);
|
||||
|
||||
if (!strcmp(var, "core.excludesfile"))
|
||||
return git_config_string(&excludes_file, var, value);
|
||||
|
||||
if (!strcmp(var, "core.whitespace")) {
|
||||
if (!value)
|
||||
return config_error_nonbool(var);
|
||||
whitespace_rule_cfg = parse_whitespace_rule(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add other config variables here and to Documentation/config.txt. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_default_config(const char *var, const char *value, void *dummy)
|
||||
{
|
||||
if (!prefixcmp(var, "core."))
|
||||
return git_default_core_config(var, value);
|
||||
|
||||
if (!strcmp(var, "user.name")) {
|
||||
if (!value)
|
||||
return config_error_nonbool(var);
|
||||
@ -473,21 +498,6 @@ int git_default_config(const char *var, const char *value, void *dummy)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.pager"))
|
||||
return git_config_string(&pager_program, var, value);
|
||||
|
||||
if (!strcmp(var, "core.editor"))
|
||||
return git_config_string(&editor_program, var, value);
|
||||
|
||||
if (!strcmp(var, "core.excludesfile"))
|
||||
return git_config_string(&excludes_file, var, value);
|
||||
|
||||
if (!strcmp(var, "core.whitespace")) {
|
||||
if (!value)
|
||||
return config_error_nonbool(var);
|
||||
whitespace_rule_cfg = parse_whitespace_rule(value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "branch.autosetupmerge")) {
|
||||
if (value && !strcasecmp(value, "always")) {
|
||||
git_branch_track = BRANCH_TRACK_ALWAYS;
|
||||
|
Loading…
Reference in New Issue
Block a user