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

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

From
Mike Ralphson <mike.ralphson@gmail.com>
Date
Feb 26, 2009, 11:19 UTC
Message-ID
<e2b179460902260319je8ce6c6qc028d260b9d35b7c@mail.gmail.com>
In-Reply-To
<49A65EBF.10307@viscovery.net>
2009/2/26 Johannes Sixt <j.sixt@viscovery.net>
Show 12 quoted lines
>
> 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

From a bit of instrumenting (no working gdb here), I see that in wrapper.c/odb_mkstemp, template is empty on entry, empty before the call to safe_create_leading_directories, but contains .git/objects/pack/tmp_pack_XXXXXX after the second snprintf. TMPDIR is not set here, which I thought might be the root cause, but it doesn't seem to be that.

My naive solution is to:
index b07cdf2..80fee48 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -268,9 +268,9 @@ int odb_mkstemp(char *template, size_t limit,
const char *pattern)
                return fd;

        /* slow path */
-       safe_create_leading_directories(template);
        snprintf(template, limit, "%s/%s",
                 get_object_directory(), pattern);
+       safe_create_leading_directories(template);
        return xmkstemp(template);
 }

Which then passes all tests.

Bearing in mind that for me, fiddling with C is like trying to order
room service in Latin, if this is in any way the correct thing to do,
I'll post a proper patch with s-o-b if required, or you can just
squash into j6t's.

Mike
Previous: Johannes SixtNext: Johannes Sixt
Message 7 of 10 in “git-push error: Cannot write keep file”
  1. Rafael Darder CalvoFeb 24, 2009
  2. Junio C HamanoFeb 24, 2009
  3. Rafael Darder CalvoFeb 24, 2009
  4. Make sure objects/pack exists before creating a new packJunio C Hamano, Feb 25, 2009
  5. Junio C HamanoFeb 25, 2009
  6. Johannes SixtFeb 26, 2009
  7. Mike RalphsonFeb 26, 2009
  8. Johannes SixtFeb 26, 2009
  9. Mike RalphsonFeb 26, 2009
  10. Junio C HamanoFeb 26, 2009

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.