The good news is: it won't mess up your Git no more.
Because, with Git 2.25 (Q1 2020), Git will forbid pathnames that the platform's filesystem cannot represent on MinGW.
See commit 4dc42c6, commit 98d9b23 (21 Dec 2019) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit 13432fc, 02 Jan 2020)
mingw
: refuse paths containing reserved names
Signed-off-by: Johannes Schindelin
There are a couple of reserved names that cannot be file names on Windows, such as AUX
, NUL
, etc.
For an almost complete list, see "Naming Files, Paths, and Namespaces: 'Naming Conventions'".
If one would try to create a directory named NUL
, it would actually "succeed", i.e. the call would return success, but nothing would be created.
Worse, even adding a file extension to the reserved name does not make it a valid file name.
To understand the rationale behind that behavior, see "What's the deal with those reserved filenames like NUL
and CON
?" from Raymond Chen.
Let's just disallow them all.
Git 2.27 (Q2 2020) fixes another issue with COM0
.
See commit 3efc128 (09 Apr 2020), and commit b6852e1 (08 Apr 2020) by Johannes Schindelin (dscho
).
See commit a748f3f (08 Apr 2020) by Matthias Aßhauer (rimrul
).
(Merged by Junio C Hamano -- gitster
-- in commit b3eb70e, 22 Apr 2020)
mingw
: do not treat COM0
as a reserved file name
Signed-off-by: Johannes Schindelin
In 4dc42c6c186 ("mingw
: refuse paths containing reserved names", 2019-12-21, Git v2.25.0-rc1 -- merge), we started disallowing file names that are reserved, e.g. NUL
, CONOUT$
, etc.
This included COM<n>
where <n>
is a digit.
Unfortunately, this includes COM0
but only COM1
, ..., COM9
are reserved, according to the official documentation, COM0
is mentioned in the "NT Namespaces" section but it is explicitly omitted from the list of reserved names: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
Tests corroborate this: it is totally possible to write a file called com0.c
on Windows 10, but not com1.c
.
So let's tighten the code to disallow only the reserved COM<n>
file names, but to allow COM0
again.
This fixes git-for-windows/git
issue 2470 "Cannot add file COM0.c
or checkout branch containing COM0.c
file".