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

Re: [BUG] Destructive access to an "objects/info/alternates" repository

From
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Date
Jan 4, 2021, 13:54 UTC
Message-ID
<20210104135410.myjaygaulqnxcnsc@chatter.i7.local>
In-Reply-To
<jwv1rf26k9n.fsf-monnier+gmane.comp.version-control.git@gnu.org>
On Sun, Jan 03, 2021 at 11:50:35AM -0500, Stefan Monnier wrote:
Show 15 quoted lines
> >> FWIW, I just tried it with
> >> 
> >>     git clone --shared ~otheruser/nongnu
> >> 
> >> and got the same result.
> >> I also tried with another repository, still with the same result (tho
> >> different pack.idx names, of course).
> >
> > I've tried several times to reproduce this, but I am unable to do so. You may
> > need to provide the tarball with ~otheruser/nongnu contents for someone to be
> > able to properly debug this.
> 
> OK, you can try with the following tarball:
> 
>     https://www.iro.umontreal.ca/~monnier/nongnu.tar.gz

Great, thank you for providing that. At this point, I can verify the behaviour you are seeing:

$ cat .git/objects/info/alternates /tmp/test/nongnu/.git/objects $ git gc Enumerating objects: 119, done. Nothing new to pack. warning: unable to unlink '/tmp/test/nongnu/.git/objects/pack/pack-0d85e74ac2f7e51ce26f281e64eb738e8182fa95.idx': Permission denied warning: unable to unlink '/tmp/test/nongnu/.git/objects/pack/pack-5fe14feff49ccdee5469af9dc94f6784e8464a6b.idx': Permission denied

Notably, if I run repack/prune by themselves, this does not happen:

$ git repack -Adln Enumerating objects: 119, done. Nothing new to pack. $ git prune --expire=now $

I would guess that this is happening in builtin/gc.c#686 [1], where it calls clean_pack_garbage(). Running "git count-objects -v" shows:

$ git count-objects -v warning: no corresponding .pack: /tmp/test/nongnu/.git/objects/pack/pack-0d85e74ac2f7e51ce26f281e64eb738e8182fa95.idx warning: no corresponding .pack: /tmp/test/nongnu/.git/objects/pack/pack-5fe14feff49ccdee5469af9dc94f6784e8464a6b.idx count: 0 size: 0 in-pack: 0 packs: 0 size-pack: 0 prune-packable: 0 garbage: 2 size-garbage: 6573 alternate: /tmp/test/nongnu/.git/objects

I agree with Stefan that this is undesired behaviour, even when it only happens when attempting to clean up garbage -- git-gc (and git-count-objects) should distinguish between garbage in the parent repository and its own repository and not attempt any modification of the parent repository during gc or any other operation.

[1] https://git.kernel.org/pub/scm/git/git.git/tree/builtin/gc.c#n686
-K
Previous: Stefan MonnierNext: Stefan Monnier
Message 7 of 9 in “[BUG] Destructive access to an "objects/info/alternates" repository”
  1. Stefan MonnierDec 28, 2020
  2. Konstantin RyabitsevDec 28, 2020
  3. Stefan MonnierDec 28, 2020
  4. Stefan MonnierDec 28, 2020
  5. Konstantin RyabitsevDec 29, 2020
  6. Stefan MonnierJan 3, 2021
  7. Konstantin RyabitsevJan 4, 2021
  8. Stefan MonnierJan 4, 2021
  9. Konstantin RyabitsevJan 4, 2021

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.