From: "brian m. carlson" <firstname.lastname@example.org> To: Mark Amery <email@example.com> Cc: firstname.lastname@example.org Subject: Re: Bug: Changing folder case with `git mv` crashes on case-insensitive file system Date: Mon, 3 May 2021 22:58:14 +0000 [thread overview] Message-ID: <YJCABtAGT7s70jl1@camp.crustytoothpaste.net> (raw) In-Reply-To: <CAD8jeghpOQoibk0xM0QgLsOwLNw9GdM=4rhYuzV-NSkw8LinMQ@mail.gmail.com> [-- Attachment #1: Type: text/plain, Size: 2929 bytes --] On 2021-05-03 at 17:25:43, Mark Amery wrote: > Attempting to change the case of a folder's name using a command like > `git mv foo FOO` crashes on case-insensitive file systems, like the > default APFS used on Apple Macs. > > Here are simple steps to repro this: > > $ mkdir testrepo && cd testrepo && git init > Initialized empty Git repository in /Users/markamery/testrepo/.git/ > $ mkdir foo && touch foo/bar && git add foo && git commit -m bla > [master (root-commit) a7e9f5f] bla > 1 file changed, 0 insertions(+), 0 deletions(-) > create mode 100644 foo/bar > $ git mv foo FOO > fatal: renaming 'foo' failed: Invalid argument > $ echo $? > 128 > $ git status > On branch master > nothing to commit, working tree clean > > If I create a case-sensitive APFS volume using Disk Utility and try > the commands above on that volume, `git mv foo FOO` works correctly: > it emits no output, exits with a 0 status code, and stages a change > renaming `foo/bar` to `FOO/bar`. However, on my main case-insensitive > volume, `git mv` behaves as shown above: it exits with code 128, > prints an "Invalid argument" error message, and does not stage any > changes. 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. > The command still fails in the same way if you use `git mv --force` > instead of just `git mv`. > > Note that previously, `git mv` could not change the case of *file* > names on case-insensitive file systems, until that was fixed in commit > https://github.com/git/git/commit/baa37bff9a845471754d3f47957d58a6ccc30058. > I'm guessing there's a different code path that needs fixing for > changing the case of *folders*. My guess is this is because when the argument is a directory, the mode is set to WORKING_DIRECTORY, and then we check that the mode isn't INDEX and so rename(2) gets called. However, I believe there is a -k option which should make this work, since we ignore the errors. 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. Maybe someone who frequently uses a macOS system that uses a case-sensitive file system can chime in here, but for now, I think -k should do what you want. -- brian m. carlson (he/him or they/them) Houston, Texas, US [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2021-05-03 22:58 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-03 17:25 Mark Amery 2021-05-03 22:58 ` brian m. carlson [this message] 2021-05-04 3:46 ` Junio C Hamano 2021-05-04 11:20 ` brian m. carlson 2021-05-05 13:51 ` Johannes Schindelin 2021-05-06 0:38 ` Junio C Hamano 2021-05-04 15:19 ` Torsten Bögershausen 2021-05-05 0:23 ` Junio C Hamano 2021-05-05 2:12 ` brian m. carlson 2021-05-06 4:34 ` Torsten Bögershausen 2021-05-06 9:12 ` Mark Amery 2021-05-06 13:11 ` Bagas Sanjaya 2021-05-06 14:53 ` Torsten Bögershausen 2021-05-06 21:03 ` Junio C Hamano
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YJCABtAGT7s70jl1@camp.crustytoothpaste.net \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: Bug: Changing folder case with `git mv` crashes on case-insensitive file system' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).