[PATCH v4 11/13] mingw: ensure valid CTYPE
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Sep 10, 2026, 06:05 UTC
- Message-ID
- <1bbd0dc6aaa362a942d47fc2e4630ca6e7f14cd1.1789020327.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2195.v4.git.1789020327.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
A change between versions 2.4.1 and 2.6.0 of the MSYS2 runtime modified how Cygwin's runtime (and hence Git for Windows' MSYS2 runtime derivative) handles locales: d16a56306d (Consolidate wctomb/mbtowc calls for POSIX-1.2008, 2016-07-20).
An unintended side-effect is that "cold-calling" into the POSIX emulation will start with a locale based on the current code page, something that Git for Windows is very ill-prepared for, as it expects to be able to pass a command-line containing non-ASCII characters to the shell without having those characters munged.
One symptom of this behavior: when `git clone` or `git fetch` shell out to call `git-upload-pack` with a path that contains non-ASCII characters, the shell tried to interpret the entire command-line (including command-line parameters) as executable path, which obviously must fail.
This fixes https://github.com/git-for-windows/git/issues/1036
Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- compat/mingw.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/compat/mingw.c b/compat/mingw.c index e0fbd2c66d..afdc1ef2db 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -3185,6 +3185,9 @@ static void setup_windows_environment(void) if (!tmp && (tmp = getenv("USERPROFILE"))) setenv("HOME", tmp, 1); } + + if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG")) + setenv("LC_CTYPE", "C.UTF-8", 1); } int mingw_platform_has_symlinks(void)
-- gitgitgadget