Add check for illegal Windows filenames
There are file and directory names which are legal in Git and most operating systems but illegal in Windows. They should be avoided in case a developer happens to use Windows.
The following names are illegal as bare names as well as with extensions regardless of case for files or directories. For instance CoM6, cOm6.txt, com6.foo.jpg, etc are all illegal. Windows will refuse to create those files if you try to check them out.
From: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.
seems like a good idea in line with the spirit of the repository! 👍
i would suggest splitting the check between Win32 and WinNT, even if WinObj does a good job
@theGASK sorry what?
Any progress on this?
Just needs to be merged. It's a new standalone check. My opinion should even make it into the default sample config.
Just needs to be merged
the PR has a bunch of un-addressed feedback
@asottile Would you want somebody to pick up the PR you already reviewed or prefer if somebody worked on the language: fail solution you suggested there?
the original author seems to not be interested in fixing their PR so yeah I would appreciate a new one -- probably just language: fail since it'll be simpler and faster
+1 on this :) I would also suggest checking for characters which cannot be used on windows, such as :.
By the way this is a problem in WSL which has led to a lot of pain for me in the past. One contributor had committed a file:Zone.Identifier file which is generated due to downloaded files from the web (see https://github.com/microsoft/WSL/issues/4609). This was a HUGE pain to remove as it broke the repository on Windows. I would even suggest explicitly checking for that sort of file, but a hook checking for bad characters such as : would help.