aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-06-18 14:37:18 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-18 16:50:22 -0700
commit806e2ad7fe2d94e1ecae904c33b822b3dfac57f6 (patch)
tree3fbfddd9c0ae8b509142ffca3f4f48c4b537dc3d /config.c
parente449f105805ffa49ccf7cf080db897ecf65a1a0f (diff)
downloadgit-806e2ad7fe2d94e1ecae904c33b822b3dfac57f6.tar.gz
git-806e2ad7fe2d94e1ecae904c33b822b3dfac57f6.tar.xz
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>
Diffstat (limited to 'config.c')
-rw-r--r--config.c42
1 files changed, 26 insertions, 16 deletions
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;