Add check for illegal Windows filenames · Issue #589 · pre-commit/pre-commit-hooks (original) (raw)
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.