diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 82 |
1 files changed, 62 insertions, 20 deletions
@@ -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,33 @@ 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, "core.fsyncobjectfiles")) { + fsync_object_files = git_config_bool(var, value); + return 0; + } + + /* Add other config variables here and to Documentation/config.txt. */ + return 0; +} + +static int git_default_user_config(const char *var, const char *value) +{ if (!strcmp(var, "user.name")) { if (!value) return config_error_nonbool(var); @@ -462,32 +489,24 @@ 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; +} + +static int git_default_i18n_config(const char *var, const char *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; - } - - 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); + /* Add other config variables here and to Documentation/config.txt. */ + return 0; +} - if (!strcmp(var, "core.whitespace")) { - if (!value) - return config_error_nonbool(var); - whitespace_rule_cfg = parse_whitespace_rule(value); - 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; @@ -516,6 +535,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; |