简体   繁体   中英

Git: list case-sensitive paths that have collided during clone

When cloning a git repository that contains case-sensitive file paths (eg /README.md and /readme.md) on a case-insensitive file system (like NTFS or APFS), git will only check out one of the colliding files.

In macOS, how can I list all the files that collided because of case insensitivity?

There is no built in thing to find this. phd's comment will get you close, possibly close enough, but may over-fit a bit (although one might still like to know about these things).

For instance, suppose some commit has files:

path/TO/file1.ext
path/to/file2.ext

On your file system, only either path/TO or path/to may exist. Once one of those exists, these two files will be dropped into the same path/$to folder, where $to is either lowercase or uppercase. They will still be separate files, but will be called out by case-folding and sort-and-unique-dash-c-ing.

On macOS, we can also have collisions in paths due to Unicode normalization. Linux considers a file named 's' 'c' 'h' 'combining-umlaut' 'o' 'n' to be one file name, and a file named 's' 'c' 'h' 'o-with-umlaut' 'n' to be a second, different file name. The macOS default file systems will turn both names into a common form and claim that this is just one name. (I have no idea what Windows does with this.) A proper tool will should take this into account as well.

Note that Git will store each file separately in the index, and can update each separate index entry from a file-system-stored-file independent of the stored-file's path name. So we could have Git build a mapping from internal name to external name and make it handle these cases all automatically. But that's a pretty big task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM