Commit e95849c1 by schu

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>
parent be00b00d
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment