From c7a8a9aa88c0223a02f469699162aed1990b2932 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 21 Feb 2017 13:47:16 +0100 Subject: [PATCH] git: remove LC_ALL magic from the git-wrapper The idea was to allow non-ASCII characters to be passed about freely. However, in the meantime it was discovered that the only part of Git for Windows that cannot handle non-ASCII characters without LC_* being set appropriately is the POSIX emulation layer (also known as MSYS2 runtime). Meaning that the git-wrapper is the wrong place to fix this: instead, we just changed `git.exe` to ensure that LC_* is set. This way, the git-wrapper can still call Git Bash (which initializes the locales appropriately itself and would suffer from an incorrectly pre-set LC_ALL or LC_CTYPE). This fixes https://github.com/git-for-windows/git/issues/1036 Signed-off-by: Johannes Schindelin --- mingw-w64-git/git-wrapper.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/mingw-w64-git/git-wrapper.c b/mingw-w64-git/git-wrapper.c index 1a4e88ee25a1e..06d4ed46d19cc 100644 --- a/mingw-w64-git/git-wrapper.c +++ b/mingw-w64-git/git-wrapper.c @@ -37,8 +37,7 @@ static void print_error(LPCWSTR prefix, DWORD error_number) LocalFree((HLOCAL)buffer); } -static void setup_environment(LPWSTR top_level_path, int full_path, - int needs_lc_all) +static void setup_environment(LPWSTR top_level_path, int full_path) { WCHAR msystem[64]; LPWSTR path2 = NULL; @@ -49,10 +48,6 @@ static void setup_environment(LPWSTR top_level_path, int full_path, L"MINGW%d", (int) sizeof(void *) * 8); SetEnvironmentVariable(L"MSYSTEM", msystem); - /* if not set, set LC_ALL to allow non-ASCII characters */ - if (needs_lc_all && !GetEnvironmentVariable(L"LC_ALL", NULL, 0)) - SetEnvironmentVariable(L"LC_ALL", L"C.UTF-8"); - /* if not set, set PLINK_PROTOCOL to ssh */ if (!GetEnvironmentVariable(L"PLINK_PROTOCOL", NULL, 0)) SetEnvironmentVariable(L"PLINK_PROTOCOL", L"ssh"); @@ -496,7 +491,7 @@ int main(void) int r = 1, wait = 1, prefix_args_len = -1, needs_env_setup = 1, is_git_command = 1, full_path = 1, skip_arguments = 0, allocate_console = 0, show_console = 0, - append_quote_to_cmdline = 0, needs_lc_all = 0; + append_quote_to_cmdline = 0; WCHAR exepath[MAX_PATH], exe[MAX_PATH], top_level_path[MAX_PATH]; LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename; LPWSTR working_directory = NULL; @@ -561,7 +556,6 @@ int main(void) } else if (!wcsicmp(basename, L"git.exe")) { initialize_top_level_path(top_level_path, exepath, NULL, 1); - needs_lc_all = 1; /* set the default exe module */ wcscpy(exe, top_level_path); @@ -599,7 +593,7 @@ int main(void) initialize_top_level_path(top_level_path, exepath, msystem_bin, -4); - setup_environment(top_level_path, full_path, needs_lc_all); + setup_environment(top_level_path, full_path); } cmd = fixup_commandline(exepath, &exep, &wait, prefix_args, prefix_args_len, is_git_command, skip_arguments,