diff options
author | schu <schu-github@schulog.org> | 2011-12-16 11:39:21 +0100 |
---|---|---|
committer | schu <schu-github@schulog.org> | 2011-12-19 16:07:21 +0100 |
commit | e95849c14f8c62a99f04600bb3a4f677156a78bd (patch) | |
tree | fd2b83deaf8038ef59285574b7e9bfb2b418bc6e | |
parent | be00b00dd1468f1c625ca3fadc61f2a16edfb8d5 (diff) | |
download | libgit2-e95849c14f8c62a99f04600bb3a4f677156a78bd.tar.gz |
config_file: honor error
Return an error if we can't write an updated version of the config file
after config_delete.
Along with that, fix an uninitialized warning.
Signed-off-by: schu <schu-github@schulog.org>
-rw-r--r-- | src/config_file.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/config_file.c b/src/config_file.c index 207bd2bdd..afa917a0b 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -406,7 +406,8 @@ static int config_get(git_config_file *cfg, const char *name, const char **out) static int config_delete(git_config_file *cfg, const char *name) { - cvar_t *iter, *prev; + int error; + cvar_t *iter, *prev = NULL; diskfile_backend *b = (diskfile_backend *)cfg; CVAR_LIST_FOREACH (&b->var_list, iter) { @@ -419,9 +420,11 @@ static int config_delete(git_config_file *cfg, const char *name) git__free(iter->value); iter->value = NULL; - config_write(b, iter); + error = config_write(b, iter); cvar_free(iter); - return GIT_SUCCESS; + return error == GIT_SUCCESS ? + GIT_SUCCESS : + git__rethrow(error, "Failed to update config file"); } /* Store it for the next round */ prev = iter; |