From 806e2ad7fe2d94e1ecae904c33b822b3dfac57f6 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 18 Jun 2008 14:37:18 -0700 Subject: 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 --- config.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index c2f2bbb000..c3597e0432 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; -- cgit v1.2.1 From d1364529d06e5fa3bc054396299944a7a4861776 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 18 Jun 2008 14:40:35 -0700 Subject: Split up default "user" config parsing into helper routine This follows the example of the "core" config, and splits out the default "user" config option parsing into a helper routine. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- config.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index c3597e0432..ee7642bf6c 100644 --- a/config.c +++ b/config.c @@ -464,11 +464,8 @@ static int git_default_core_config(const char *var, const char *value) return 0; } -int git_default_config(const char *var, const char *value, void *dummy) +static int git_default_user_config(const char *var, const char *value) { - if (!prefixcmp(var, "core.")) - return git_default_core_config(var, value); - if (!strcmp(var, "user.name")) { if (!value) return config_error_nonbool(var); @@ -487,6 +484,18 @@ int git_default_config(const char *var, const char *value, void *dummy) 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 (!prefixcmp(var, "user.")) + return git_default_user_config(var, value); + if (!strcmp(var, "i18n.commitencoding")) return git_config_string(&git_commit_encoding, var, value); -- cgit v1.2.1 From 1141f4925c3f1d7c8cc476b10107209e56909c6d Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 18 Jun 2008 15:00:11 -0700 Subject: Split up default "i18n" and "branch" config parsing into helper routines .. just to finish it off. We'll leave the pager color config alone, since it is such an odd-ball special case anyway. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- config.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index ee7642bf6c..9d14a74f82 100644 --- a/config.c +++ b/config.c @@ -488,25 +488,20 @@ static int git_default_user_config(const char *var, const char *value) return 0; } -int git_default_config(const char *var, const char *value, void *dummy) +static int git_default_i18n_config(const char *var, const char *value) { - if (!prefixcmp(var, "core.")) - return git_default_core_config(var, value); - - if (!prefixcmp(var, "user.")) - return git_default_user_config(var, value); - if (!strcmp(var, "i18n.commitencoding")) return git_config_string(&git_commit_encoding, var, value); if (!strcmp(var, "i18n.logoutputencoding")) return git_config_string(&git_log_output_encoding, var, value); - if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { - pager_use_color = git_config_bool(var,value); - return 0; - } + /* Add other config variables here and to Documentation/config.txt. */ + return 0; +} +static int git_default_branch_config(const char *var, const char *value) +{ if (!strcmp(var, "branch.autosetupmerge")) { if (value && !strcasecmp(value, "always")) { git_branch_track = BRANCH_TRACK_ALWAYS; @@ -535,6 +530,29 @@ int git_default_config(const char *var, const char *value, void *dummy) 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 (!prefixcmp(var, "user.")) + return git_default_user_config(var, value); + + if (!prefixcmp(var, "i18n.")) + return git_default_i18n_config(var, value); + + if (!prefixcmp(var, "branch.")) + return git_default_branch_config(var, value); + + if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { + pager_use_color = git_config_bool(var,value); + return 0; + } + + /* Add other config variables here and to Documentation/config.txt. */ + return 0; +} + int git_config_from_file(config_fn_t fn, const char *filename, void *data) { int ret; -- cgit v1.2.1 From aafe9fbaf4f1d1f27a6f6e3eb3e246fff81240ef Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 18 Jun 2008 15:18:44 -0700 Subject: Add config option to enable 'fsync()' of object files As explained in the documentation[*] this is totally useless on filesystems that do ordered/journalled data writes, but it can be a useful safety feature on filesystems like HFS+ that only journal the metadata, not the actual file contents. It defaults to off, although we could presumably in theory some day auto-enable it on a per-filesystem basis. [*] Yes, I updated the docs for the thing. Hell really _has_ frozen over, and the four horsemen are probably just beyond the horizon. EVERYBODY PANIC! Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- config.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index 9d14a74f82..b2d5b4e4e3 100644 --- a/config.c +++ b/config.c @@ -460,6 +460,11 @@ static int git_default_core_config(const char *var, const char *value) return 0; } + if (!strcmp(var, "core.fsyncobjectfiles")) { + fsync_object_files = git_config_bool(var, value); + return 0; + } + /* Add other config variables here and to Documentation/config.txt. */ return 0; } -- cgit v1.2.1