diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-16 00:20:37 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-16 00:20:37 -0800 |
commit | d5558581d2583d18cdb6823065a8f812085fbc37 (patch) | |
tree | 9d9c40072aedd0fd0aaa5a717a5c56e54847a6cd /config.c | |
parent | aa8d53ec387a7baf72ab5e3a91c35bb5bf20eb4d (diff) | |
parent | 959ba670ad7173bcb73afaca69625a5635f63b8b (diff) | |
download | git-d5558581d2583d18cdb6823065a8f812085fbc37.tar.gz |
Merge branch 'maint'
* maint:
commit: discard index after setting up partial commit
filter-branch: handle filenames that need quoting
diff: Fix miscounting of --check output
hg-to-git: fix parent analysis
mailinfo: feed only one line to handle_filter() for QP input
diff.c: add "const" qualifier to "char *cmd" member of "struct ll_diff_driver"
Add "const" qualifier to "char *excludes_file".
Add "const" qualifier to "char *editor_program".
Add "const" qualifier to "char *pager_program".
config: add 'git_config_string' to refactor string config variables.
diff.c: remove useless check for value != NULL
fast-import: check return value from unpack_entry()
Validate nicknames of remote branches to prohibit confusing ones
diff.c: replace a 'strdup' with 'xstrdup'.
diff.c: fixup garding of config parser from value=NULL
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 49 |
1 files changed, 18 insertions, 31 deletions
@@ -309,6 +309,14 @@ int git_config_bool(const char *name, const char *value) return git_config_int(name, value) != 0; } +int git_config_string(const char **dest, const char *var, const char *value) +{ + if (!value) + return config_error_nonbool(var); + *dest = xstrdup(value); + return 0; +} + int git_default_config(const char *var, const char *value) { /* This needs a better name */ @@ -421,46 +429,25 @@ int git_default_config(const char *var, const char *value) return 0; } - if (!strcmp(var, "i18n.commitencoding")) { - if (!value) - return config_error_nonbool(var); - git_commit_encoding = xstrdup(value); - return 0; - } - - if (!strcmp(var, "i18n.logoutputencoding")) { - if (!value) - return config_error_nonbool(var); - git_log_output_encoding = xstrdup(value); - return 0; - } + 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")) { - if (!value) - return config_error_nonbool(var); - pager_program = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.pager")) + return git_config_string(&pager_program, var, value); - if (!strcmp(var, "core.editor")) { - if (!value) - return config_error_nonbool(var); - editor_program = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.editor")) + return git_config_string(&editor_program, var, value); - if (!strcmp(var, "core.excludesfile")) { - if (!value) - return config_error_nonbool(var); - excludes_file = xstrdup(value); - return 0; - } + if (!strcmp(var, "core.excludesfile")) + return git_config_string(&excludes_file, var, value); if (!strcmp(var, "core.whitespace")) { if (!value) |