From 9ed38942e043d5d4d7d479a7d2e0990b0157ca38 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Fri, 8 May 2015 00:31:33 +0200 Subject: [PATCH] git-wrapper: don't set the console input code page Using different code pages for console input (SetConsoleCP()) and console output (SetConsoleOutputCP()) doesn't make much sense and may be hazardous for native Windows programs. Git uses UTF-8 internally, so it actually needs 'SetConsoleCP(CP_UTF8)' rather than 'SetConsoleCP(GetACP())'. However, ReadFile() / ReadConsoleA() are broken with CP_UTF8 (and thus any higher level APIs such as fgetc(), getchar() etc.). Unicode-aware console input would have to be implemented via mingw_* wrappers using ReadConsoleW(). As Git typically launches an editor for anything more complex than ASCII-only, yes/no-style questions, this is currently not a problem. Drop 'SetConsoleCP()' from the git-wrapper, so that input and output code pages stay in sync. Signed-off-by: Karsten Blees --- compat/win32/git-wrapper.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/compat/win32/git-wrapper.c b/compat/win32/git-wrapper.c index 093d20838e8d1b..f888064defb232 100644 --- a/compat/win32/git-wrapper.c +++ b/compat/win32/git-wrapper.c @@ -321,7 +321,6 @@ int main(void) WCHAR exepath[MAX_PATH], exe[MAX_PATH]; LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename; LPWSTR working_directory = NULL; - UINT codepage = 0; /* Determine MSys2-based Git path. */ swprintf(msystem_bin, sizeof(msystem_bin), @@ -437,10 +436,6 @@ int main(void) } } - /* set the console to ANSI/GUI codepage */ - codepage = GetConsoleCP(); - SetConsoleCP(GetACP()); - { STARTUPINFO si; PROCESS_INFORMATION pi; @@ -499,7 +494,5 @@ int main(void) free(cmd); - /* reset the console codepage */ - SetConsoleCP(codepage); ExitProcess(r); }