Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: [PATCH] builtin-checkout: use struct lock_file correctly
Date: Thu, 14 Feb 2008 18:17:05 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LSU.1.00.0802141816120.30505@racer.site> (raw)
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

  reply	other threads:[~2008-02-14 18:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-07 16:40 [PATCH v2 11/11] Build in checkout Daniel Barkalow
2008-02-14 18:17 ` Johannes Schindelin [this message]
2008-02-14 18:22   ` [PATCH] builtin-checkout: use struct lock_file correctly Daniel Barkalow
2008-02-14 18:55     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.1.00.0802141816120.30505@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox