summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-12-20 16:48:36 +0700
committerJunio C Hamano <gitster@pobox.com>2016-12-22 12:31:50 -0800
commitc06fa62dfc9c882f60250e60ad91fbb6a7e6f8e7 (patch)
treedb3221f8e8998ec4302bd797fa6af89de65efe8a /config.c
parent6e45b43fa9c17124c5aea03b3fd6563cf03bae07 (diff)
downloadgit-c06fa62dfc9c882f60250e60ad91fbb6a7e6f8e7.tar.gz
config.c: handle lock file in error case in git_config_rename_...nd/config-misc-fixes
We could rely on atexit() to clean up everything, but let's be explicit when we can. And it's good anyway because the function is called the second time in the same process, we're in trouble. This function should not affect the successful case because after commit_lock_file() is called, rollback_lock_file() becomes no-op, as long as it is initialized. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/config.c b/config.c
index 8065296a11..398ffec29d 100644
--- a/config.c
+++ b/config.c
@@ -2314,7 +2314,7 @@ int git_config_rename_section_in_file(const char *config_filename,
if (new_name && !section_name_is_ok(new_name)) {
ret = error("invalid section name: %s", new_name);
- goto out;
+ goto out_no_rollback;
}
if (!config_filename)
@@ -2396,6 +2396,8 @@ commit_and_out:
ret = error_errno("could not write config file %s",
config_filename);
out:
+ rollback_lock_file(lock);
+out_no_rollback:
free(filename_buf);
return ret;
}