Skip to content

Commit be2c77b

Browse files
committed
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 <[email protected]>
1 parent dc31b9b commit be2c77b

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

compat/win32/git-wrapper.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ int main(void)
316316
WCHAR exepath[MAX_PATH], exe[MAX_PATH];
317317
LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename;
318318
LPWSTR working_directory = NULL;
319-
UINT codepage = 0;
320319

321320
/* Determine MSys2-based Git path. */
322321
swprintf(msystem_bin, sizeof(msystem_bin),
@@ -431,10 +430,6 @@ int main(void)
431430
}
432431
}
433432

434-
/* set the console to ANSI/GUI codepage */
435-
codepage = GetConsoleCP();
436-
SetConsoleCP(GetACP());
437-
438433
{
439434
STARTUPINFO si;
440435
PROCESS_INFORMATION pi;
@@ -489,7 +484,5 @@ int main(void)
489484

490485
free(cmd);
491486

492-
/* reset the console codepage */
493-
SetConsoleCP(codepage);
494487
ExitProcess(r);
495488
}

0 commit comments

Comments
 (0)