Skip to content

Commit

Permalink
Split up default "core" config parsing into helper routine
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Jun 18, 2008
1 parent e449f10 commit 806e2ad
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 806e2ad

Please sign in to comment.