git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] config.c: handle lock file in error case in git_config_rename_...

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 20, 2016, 09:48 UTC
Message-ID
<20161220094836.4131-2-pclouds@gmail.com>
In-Reply-To
<20161220094836.4131-1-pclouds@gmail.com>

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.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 config.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/config.c b/config.c
index 505e0d0..e02def4 100644
--- a/config.c
+++ b/config.c
@@ -2483,6 +2483,7 @@ 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);
 	free(filename_buf);
 	return ret;
 }
-- 
2.8.2.524.g6ff3d78
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 6 of 7 in “Segfault in git_config_set_multivar_in_file_gently with direct_io in FUSE filesystem”
  1. Josh Bleecher SnyderDec 16, 2016
  2. config.c: handle error case for fstat() callsNguyễn Thái Ngọc Duy, Dec 19, 2016
  3. Junio C HamanoDec 19, 2016
  4. Duy NguyenDec 20, 2016
  5. 1/2 config.c: rename label unlock_and_outNguyễn Thái Ngọc Duy, Dec 20, 2016
  6. 2/2 config.c: handle lock file in error case in git_config_rename_...Nguyễn Thái Ngọc Duy, Dec 20, 2016
  7. Junio C HamanoDec 20, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.