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

Re: Q: does index-pack work in place on windows?

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Feb 2, 2011, 20:30 UTC
Message-ID
<AANLkTi=m+kERSH7TJFjuRaUfA7FR03zwNn2PKFxrqiOp@mail.gmail.com>
In-Reply-To
<7v39o6xk5q.fsf@alter.siamese.dyndns.org>
On Wed, Feb 2, 2011 at 9:21 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 30 quoted lines
> ... or any other (operating / file) system where you cannot unlink a file
> that is open?
>
> When you run
>
>    $ git clone git://some.where/repo/sitory.git local
>    $ cd local
>    $ git index-pack .git/objects/pack/pack-*.pack
>
> there is a call to write_idx_file() in builtin/index-pack.c, that feeds
> the correct (and existing) name of the corresponding pack idx file.
>
> The callee in pack-write.c, after sorting the list of objects contained in
> the pack, does this:
>
>        if (!index_name) {
>                static char tmpfile[PATH_MAX];
>                fd = odb_mkstemp(tmpfile, sizeof(tmpfile), "pack/tmp_idx_XXXXXX");
>                index_name = xstrdup(tmpfile);
>        } else {
>                unlink(index_name);
>                fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
>        }
>
> and then writes out the pack index to the file descriptor.  But index-pack
> uses the usual has_sha1_file() and read_sha1_file() interface to validate
> the "existing" objects, and is likely to have mmapped the .idx file when
> it called use_pack_window().  Which makes me suspect that this unlink (or
> the open that immediately follows) may fail on systems that do not allow
> unlink on inode that has still users.
...and you're right:

$ git index-pack .git/objects/pack/pack-d634271f4d7ca70c00148e967a343c3c46cd7705.pack Unlink of file '.git/objects/pack/pack-d634271f4d7ca70c00148e967a343c3c46cd7705.idx' failed. Should I try again? (y/n)? n fatal: unable to create '.git/objects/pack/pack-d634271f4d7ca70c00148e967a343c3c46cd7705.idx': File exists

Previous: Junio C HamanoNext: Nicolas Pitre
Message 2 of 7 in “Q: does index-pack work in place on windows?”
  1. Junio C HamanoFeb 2, 2011
  2. Erik Faye-LundFeb 2, 2011
  3. Nicolas PitreFeb 3, 2011
  4. Junio C HamanoFeb 3, 2011
  5. Nicolas PitreFeb 4, 2011
  6. Junio C HamanoFeb 4, 2011
  7. Nicolas PitreFeb 4, 2011

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.