From: Linus Torvalds Date: Wed, 18 Jun 2008 21:37:18 +0000 (-0700) Subject: Split up default "core" config parsing into helper routine X-Git-Tag: v1.6.0-rc0~209^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=806e2ad7fe2d94e1ecae904c33b822b3dfac57f6;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/config.c b/config.c index c2f2bbb00..c3597e043 100644 --- a/config.c +++ b/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;