From d912ae6dff614da7b460415bcc981baab8ff0771 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Sep 2026 15:40:53 +0200 Subject: [PATCH] mingw: let `access()` handle `nul` whether lower-case or not The special-casing of `NUL` in `mingw_access()` was added in 9160068ac6ec5 (msvc: avoid calling `access("NUL", flags)`, 2021-04-16) because the Universal C Runtime's ("UCRT") `_waccess()` rejects `NUL` as an invalid argument. With the switch of GIt for Windows from the MSVCRT-based MINGW64 build to the UCRT-based UCRT64 build in 2.56.0, any spelling other than lowercase `nul` now reaches `_waccess()` and fails. Windows device names are case-insensitive, and `NUL` is the canonical spelling, but even `Nul` is allowed, so a case-insensitive comparison is needed. Note that we cannot use `fspathcmp()` here, as we would usually do: This function is in the code path when reading the config, and `core.ignoreCase` would therefore not be set correctly yet e.g. when running under `GIT_CONFIG_GLOBAL=NUL`. This fixes https://github.com/git-for-windows/git/issues/6449 Signed-off-by: Johannes Schindelin --- compat/mingw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index fd014eef498e55..9c5a5140790161 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1171,7 +1171,11 @@ ssize_t mingw_write(int fd, const void *buf, size_t len) int mingw_access(const char *filename, int mode) { wchar_t wfilename[MAX_LONG_PATH]; - if (!strcmp("nul", filename) || !strcmp("/dev/null", filename)) + /* + * Cannot use fspathcmp() here, this function is called _while reading + * the config_. + */ + if (!strcasecmp("nul", filename) || !strcmp("/dev/null", filename)) return 0; if (xutftowcs_long_path(wfilename, filename) < 0) return -1;