diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:19 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:19 -0800 |
commit | 225caa73f25f8577a710f406b2670c3bcf0aef34 (patch) | |
tree | fac492640e0f0fcbfe621ebd91b40a34c5bbbcb6 /config.c | |
parent | 56d4e7e6c347f8986a6621ca89ae3eec055bcf59 (diff) | |
parent | 3d1806487af395fb33d1de92633e96571b296305 (diff) | |
download | git-225caa73f25f8577a710f406b2670c3bcf0aef34.tar.gz |
Merge branch 'ps/config-error'
Many codepaths forget to check return value from git_config_set();
the function is made to die() to make sure we do not proceed when
setting a configuration variable failed.
* ps/config-error:
config: rename git_config_set_or_die to git_config_set
config: rename git_config_set to git_config_set_gently
compat: die when unable to set core.precomposeunicode
sequencer: die on config error when saving replay opts
init-db: die on config errors when initializing empty repo
clone: die on config error in cmd_clone
remote: die on config error when manipulating remotes
remote: die on config error when setting/adding branches
remote: die on config error when setting URL
submodule--helper: die on config error when cloning module
submodule: die on config error when linking modules
branch: die on config error when editing branch description
branch: die on config error when unsetting upstream
branch: report errors in tracking branch setup
config: introduce set_or_die wrappers
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 52 |
1 files changed, 40 insertions, 12 deletions
@@ -1853,15 +1853,26 @@ contline: return offset; } -int git_config_set_in_file(const char *config_filename, - const char *key, const char *value) +int git_config_set_in_file_gently(const char *config_filename, + const char *key, const char *value) { - return git_config_set_multivar_in_file(config_filename, key, value, NULL, 0); + return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0); } -int git_config_set(const char *key, const char *value) +void git_config_set_in_file(const char *config_filename, + const char *key, const char *value) { - return git_config_set_multivar(key, value, NULL, 0); + git_config_set_multivar_in_file(config_filename, key, value, NULL, 0); +} + +int git_config_set_gently(const char *key, const char *value) +{ + return git_config_set_multivar_gently(key, value, NULL, 0); +} + +void git_config_set(const char *key, const char *value) +{ + git_config_set_multivar(key, value, NULL, 0); } /* @@ -1976,9 +1987,10 @@ int git_config_key_is_valid(const char *key) * - the config file is removed and the lock file rename()d to it. * */ -int git_config_set_multivar_in_file(const char *config_filename, - const char *key, const char *value, - const char *value_regex, int multi_replace) +int git_config_set_multivar_in_file_gently(const char *config_filename, + const char *key, const char *value, + const char *value_regex, + int multi_replace) { int fd = -1, in_fd = -1; int ret; @@ -2205,11 +2217,27 @@ write_err_out: } -int git_config_set_multivar(const char *key, const char *value, - const char *value_regex, int multi_replace) +void git_config_set_multivar_in_file(const char *config_filename, + const char *key, const char *value, + const char *value_regex, int multi_replace) +{ + if (git_config_set_multivar_in_file_gently(config_filename, key, value, + value_regex, multi_replace) < 0) + die(_("Could not set '%s' to '%s'"), key, value); +} + +int git_config_set_multivar_gently(const char *key, const char *value, + const char *value_regex, int multi_replace) +{ + return git_config_set_multivar_in_file_gently(NULL, key, value, value_regex, + multi_replace); +} + +void git_config_set_multivar(const char *key, const char *value, + const char *value_regex, int multi_replace) { - return git_config_set_multivar_in_file(NULL, key, value, value_regex, - multi_replace); + git_config_set_multivar_in_file(NULL, key, value, value_regex, + multi_replace); } static int section_name_match (const char *buf, const char *name) |