提交 c06fa62d 编写于 作者: N Nguyễn Thái Ngọc Duy 提交者: Junio C Hamano

config.c: handle lock file in error case in git_config_rename_...

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: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6e45b43f
......@@ -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 @@ int git_config_rename_section_in_file(const char *config_filename,
ret = error_errno("could not write config file %s",
config_filename);
out:
rollback_lock_file(lock);
out_no_rollback:
free(filename_buf);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册