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

Re: Git gc removes all packs

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Feb 17, 2015, 22:19 UTC
Message-ID
<54E3BE8B.2040403@alum.mit.edu>
In-Reply-To
<xmqq7fvg19se.fsf@gitster.dls.corp.google.com>
On 02/17/2015 10:57 PM, Junio C Hamano wrote:
Show 24 quoted lines
> Michael Haggerty <mhagger@alum.mit.edu> writes:
> 
>> On 02/17/2015 05:55 PM, Jeff King wrote:
>>> On Tue, Feb 17, 2015 at 05:39:27PM +0100, Michael Haggerty wrote:
>>>
>>>> There's a bunch of code in refs.c that is there explicitly for reading
>>>> loose references that are symlinks. If the link contents literally start
>>>> with "refs/", then they are read and treated as a symbolic ref.
>>>> Otherwise, the symlink is just followed.
>>> ...
>> Yes, this makes sense too. But my point was that sticking symlinks to
>> random files in your refs hierarchy is pretty questionable even *before*
>> the symlink gets broken. If we would warn the user as soon as we saw
>> such a thing, then the user's problem would never have advanced as far
>> as it did. Do you think that emitting warnings on *intact* symlinks is
>> too draconian?
> 
> Do you mean that we would end up reading refs/heads/hold if the user
> did this:
> 
>     git rev-parse --verify HEAD -- >precious
>     ln -s ../../../precious .git/refs/heads/hold
> 
> because that symbolic link does not begin with "refs/",

Correct, you can do exactly that. The "hold" reference is resolvable and listable using "for-each-ref". But if I try to update it, the contents of the "precious" file are overwritten. On the other hand, if I run "pack-refs", then the current value of the "hold" reference is moved to "packed-refs" and the symlink is removed. This behavior is not sane.

> and is an
> accident waiting to happen so we should forbid it in the longer
> term and warning when we see it would be the first step?

Yes, I am proposing that approach, though if somebody can suggest a use case I'm willing to be convinced otherwise. The only thing I can imagine symlinks being useful for might be to temporarily create a fake repo, run one or two specific known-safe commands, then delete the repo again.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “Git gc removes all packs”
  1. Dmitry NeverovFeb 5, 2015
  2. Jeff KingFeb 5, 2015
  3. Michael HaggertyFeb 17, 2015
  4. Jeff KingFeb 17, 2015
  5. Michael HaggertyFeb 17, 2015
  6. Junio C HamanoFeb 17, 2015
  7. Michael HaggertyFeb 17, 2015
  8. Junio C HamanoFeb 18, 2015
  9. Dmitry NeverovFeb 27, 2015
  10. Jeff KingFeb 27, 2015

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.