[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