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

[PATCH] builtin-checkout: use struct lock_file correctly

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 14, 2008, 18:17 UTC
Message-ID
<alpine.LSU.1.00.0802141816120.30505@racer.site>
In-Reply-To
<alpine.LNX.1.00.0802071137490.13593@iabervon.org>

A lock_file instance must not be cleaned up, since an atexit() handler will try to access even correctly committed lock_files, since it has to make sure that they were correctly committed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	I am using builtin checkout since quite some time, but this is the 
	first time it crashed... That fix helps; you might want to amend 
	your patch 11/11.
 builtin-checkout.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 0894eae..12000b1 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -67,14 +67,14 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
 static int read_tree_some(struct tree *tree, const char **pathspec)
 {
 	int newfd;
-	struct lock_file lock_file;
-	newfd = hold_locked_index(&lock_file, 1);
+	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+	newfd = hold_locked_index(lock_file, 1);
 	read_cache();
 
 	read_tree_recursive(tree, "", 0, 0, pathspec, update_some);
 
 	if (write_cache(newfd, active_cache, active_nr) ||
-	    commit_locked_index(&lock_file))
+	    commit_locked_index(lock_file))
 		die("unable to write new index file");
 
 	/* update the index with the given tree's info
-- 
1.5.4.1.1353.g0d5dd
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 2 of 4 in “Build in checkout”
  1. 11/11 Build in checkoutDaniel Barkalow, Feb 7, 2008
  2. builtin-checkout: use struct lock_file correctlyJohannes Schindelin, Feb 14, 2008
  3. Daniel BarkalowFeb 14, 2008
  4. Johannes SchindelinFeb 14, 2008

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.