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

Re: Should "head" also work for "HEAD" on case-insensitive FS?

From
Jeff King <peff@peff.net>
Date
Jul 5, 2017, 08:36 UTC
Message-ID
<20170705083611.jgxbp4sqogicfwdb@sigill.intra.peff.net>
In-Reply-To
<87van8boe9.fsf@gmail.com>
On Tue, Jul 04, 2017 at 10:24:30AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 13 quoted lines
> I.e. we allow any arbitrary ref sitting in .git/, but presumably we
> could just record the original string the user provided so that this
> dies on OSX/Windows too:
> 
>     $ cp .git/{HEAD,Whatever}
>     $ git rev-parse wHATEVER
>     wHATEVER
>     fatal: ambiguous argument 'wHATEVER': unknown revision or path not in the working tree.
> 
> But this may be a much deeper rabbit hole than I initially thought, I
> was fishing to see if someone knew of a place in the code or WIP patch
> that dealt with these special refs, but between the low-level machinery
> & sha1_name.c (and others) there may be no easy one place to do this...

I think we talked at one point about allowing only [A-Z_] for top-level refs. My recollection is that it generally seemed like a good idea, but I don't think we ever had patches.

I think it would work to enforce it via check_refname_format(). That would catch reading via dwim_ref(), which is what your example is hitting. But it should also prevent people from writing ".git/foo" (or worse, ".git/config") as a ref.

I do think that's the tip of the iceberg for case-sensitivity problems with refs, though. Because packed-refs is case-sensitive, I think you can create some pretty confusing states on case-insensitive filesystems. For example:

  http://public-inbox.org/git/20150825052123.GA523@sigill.intra.peff.net/

Ultimately I think the path forward is to have a ref backend that behaves uniformly (either because it avoids the filesystem, or because it encodes around the differences). See:

  http://public-inbox.org/git/xmqqvb4udyf9.fsf@gitster.mtv.corp.google.com/
and its reply.
-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 4 of 11 in “Should "head" also work for "HEAD" on case-insensitive FS?”
  1. Ævar Arnfjörð BjarmasonJul 3, 2017
  2. Konstantin KhomoutovJul 4, 2017
  3. Ævar Arnfjörð BjarmasonJul 4, 2017
  4. Jeff KingJul 5, 2017
  5. Junio C HamanoJul 5, 2017
  6. Junio C HamanoJul 6, 2017
  7. Kenneth HsuJul 6, 2017
  8. Fwd: Should "head" also work for "HEAD" on case-insensitive FS?Michael Haggerty, Jul 27, 2017
  9. Fwd: Should "head" also work for "HEAD" on case-insensitive FS?Junio C Hamano, Jul 27, 2017
  10. Jeff KingJul 27, 2017
  11. Junio C HamanoJul 27, 2017

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.