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

Re: Bug: Changing folder case with `git mv` crashes on case-insensitive file system

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 4, 2021, 11:20 UTC
Message-ID
<YJEuBqVVa/7x+jrZ@camp.crustytoothpaste.net>
In-Reply-To
<xmqqfsz36u0r.fsf@gitster.g>
On 2021-05-04 at 03:46:12, Junio C Hamano wrote:
Show 26 quoted lines
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> 
> > Yeah, this is because your operating system returns EINVAL in this case.
> > POSIX specifies EINVAL when you're trying to make a directory a
> > subdirectory of itself.  Which, I mean, I guess is a valid
> > interpretation here, but it of course makes renaming the path needlessly
> > difficult.
> > ...
> > I suspect part of the problem here is two fold: on macOS we can't
> > distinguish an attempt to rename the path due to it folding or
> > canonicalizing to the same thing from a real attempt to move an actual
> > directory into itself.  The latter would be a problem we'd want to
> > report, and the former is not.  Unfortunately, detecting this is
> > difficult because that means we'd have to implement the macOS
> > canonicalization algorithm in Git and we don't want to do that.
> 
> I agree we'd probably need to resort to macOS specific hack (like we
> have NFS or Coda specific hacks), but it may not be too bad.
> 
> After seeing EINVAL, we can lstat src 'foo' and dst 'FOO', and
> realize that both are directories and have the same st_dev/st_ino,
> which should be fairly straightforward, no?
> 
> For that, we do not exactly have to depend on any part of macOS-ism;
> we do depend on the traditional "within the same device, inum is a
> good way to tell if two filesystem entities are the same".

Yes, although that won't work on Windows, which I don't believe has the concept of inodes and almost certainly has the same problem. CCing Dscho in case he has some ideas on how we can make this more resilient there.

In any event, I'm not planning on writing a patch for this since I have no way to test it, but I'm sure someone who uses macOS could probably write one reasonably easily.

-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Previous: Junio C HamanoNext: Johannes Schindelin
Message 4 of 14 in “Bug: Changing folder case with `git mv` crashes on case-insensitive file system”
  1. Mark AmeryMay 3, 2021
  2. brian m. carlsonMay 3, 2021
  3. Junio C HamanoMay 4, 2021
  4. brian m. carlsonMay 4, 2021
  5. Johannes SchindelinMay 5, 2021
  6. Junio C HamanoMay 6, 2021
  7. Torsten BögershausenMay 4, 2021
  8. Junio C HamanoMay 5, 2021
  9. brian m. carlsonMay 5, 2021
  10. Torsten BögershausenMay 6, 2021
  11. Mark AmeryMay 6, 2021
  12. Bagas SanjayaMay 6, 2021
  13. Torsten BögershausenMay 6, 2021
  14. Junio C HamanoMay 6, 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.