Revision 396ff7547d8b3f6a933069f048d09380d515a10b authored by Johannes Schindelin on 19 June 2019, 21:05:59 UTC, committed by Junio C Hamano on 20 June 2019, 21:03:05 UTC
Git for Windows has special code to retrieve the command-line parameters (and even the environment) in UTF-16 encoding, so that they can be converted to UTF-8. This is necessary because Git for Windows wants to use UTF-8 encoded strings throughout its code, and the main() function does not get the parameters in that encoding. To do that, we used the __wgetmainargs() function, which is not even a Win32 API function, but provided by the MINGW "runtime" instead. Obviously, this method would not work with any compiler other than GCC, and in preparation for compiling with Visual C++, we would like to avoid precisely that. Lucky us, there is a much more elegant way: we can simply implement the UTF-16 variant of `main()`: `wmain()`. To make that work, we need to link with -municode. The command-line parameters are passed to `wmain()` encoded in UTF-16, as desired, and this method also works with GCC, and also with Visual C++ after adjusting the MSVC linker flags to force it to use `wmain()`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 96a0679
File | Mode | Size |
---|---|---|
files-backend.c | -rw-r--r-- | 86.0 KB |
iterator.c | -rw-r--r-- | 10.5 KB |
packed-backend.c | -rw-r--r-- | 44.1 KB |
packed-backend.h | -rw-r--r-- | 1.2 KB |
ref-cache.c | -rw-r--r-- | 14.0 KB |
ref-cache.h | -rw-r--r-- | 8.9 KB |
refs-internal.h | -rw-r--r-- | 23.8 KB |
Computing file changes ...