Skip to content

Commit 806e2ad

Browse files
torvaldsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e449f10 commit 806e2ad

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

config.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ int git_config_string(const char **dest, const char *var, const char *value)
332332
return 0;
333333
}
334334

335-
int git_default_config(const char *var, const char *value, void *dummy)
335+
static int git_default_core_config(const char *var, const char *value)
336336
{
337337
/* This needs a better name */
338338
if (!strcmp(var, "core.filemode")) {
@@ -444,6 +444,31 @@ int git_default_config(const char *var, const char *value, void *dummy)
444444
return 0;
445445
}
446446

447+
if (!strcmp(var, "core.pager"))
448+
return git_config_string(&pager_program, var, value);
449+
450+
if (!strcmp(var, "core.editor"))
451+
return git_config_string(&editor_program, var, value);
452+
453+
if (!strcmp(var, "core.excludesfile"))
454+
return git_config_string(&excludes_file, var, value);
455+
456+
if (!strcmp(var, "core.whitespace")) {
457+
if (!value)
458+
return config_error_nonbool(var);
459+
whitespace_rule_cfg = parse_whitespace_rule(value);
460+
return 0;
461+
}
462+
463+
/* Add other config variables here and to Documentation/config.txt. */
464+
return 0;
465+
}
466+
467+
int git_default_config(const char *var, const char *value, void *dummy)
468+
{
469+
if (!prefixcmp(var, "core."))
470+
return git_default_core_config(var, value);
471+
447472
if (!strcmp(var, "user.name")) {
448473
if (!value)
449474
return config_error_nonbool(var);
@@ -473,21 +498,6 @@ int git_default_config(const char *var, const char *value, void *dummy)
473498
return 0;
474499
}
475500

476-
if (!strcmp(var, "core.pager"))
477-
return git_config_string(&pager_program, var, value);
478-
479-
if (!strcmp(var, "core.editor"))
480-
return git_config_string(&editor_program, var, value);
481-
482-
if (!strcmp(var, "core.excludesfile"))
483-
return git_config_string(&excludes_file, var, value);
484-
485-
if (!strcmp(var, "core.whitespace")) {
486-
if (!value)
487-
return config_error_nonbool(var);
488-
whitespace_rule_cfg = parse_whitespace_rule(value);
489-
return 0;
490-
}
491501
if (!strcmp(var, "branch.autosetupmerge")) {
492502
if (value && !strcasecmp(value, "always")) {
493503
git_branch_track = BRANCH_TRACK_ALWAYS;

0 commit comments

Comments
 (0)