Subject: Re: [PATCH v2] Make sure objects/pack exists before creating a new pack

From: Johannes Sixt <[email-masked]>
Date: Thu, 26 Feb 2009 16:31:52 +0100

Mike Ralphson schrieb:
> 2009/2/26 Johannes Sixt <[email-masked]>
>> Junio C Hamano schrieb:
>>> @@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
>>>
>>>       if (keep_msg) {
>>>               int keep_fd, keep_msg_len = strlen(keep_msg);
>>> -             if (!keep_name) {
>>> -                     snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
>>> -                              get_object_directory(), sha1_to_hex(sha1));
>>> -                     keep_name = name;
>> You should not have removed this line...
> 
> Even with j6t's patch, I'm seeing failures in t5300--pack-object.sh on AIX 5.3
> 
> * FAIL 15: survive missing objects/pack directory
> fatal: Unable to create temporary file (): No such file or directory

I can confirm this. Your patch is good. I wrapped it up:

-- snip --
From: Mike Ralphson <[email-masked]>
Subject: [PATCH] Fix odb_mkstemp() on AIX

The AIX mkstemp() modifies its template parameter to an empty string if
the call fails.  The existing code had already recomputed the template,
but too late to be good.

See also 6ff6af62, which fixed this problem in a different spot.

Signed-off-by: Johannes Sixt <[email-masked]>
---
 wrapper.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index b07cdf2..d8efb13 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -268,9 +268,10 @@ int odb_mkstemp(char *template, size_t limit,
 		return fd;

 	/* slow path */
-	safe_create_leading_directories(template);
+	/* some mkstemp implementations erase template on failure */
 	snprintf(template, limit, "%s/%s",
 		 get_object_directory(), pattern);
+	safe_create_leading_directories(template);
 	return xmkstemp(template);
 }

-- 
1.6.1.rc1.5.gf691f