From 033bb5ecb5974f41415acc9e94ee488b01f10763 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 14 Mar 2017 12:25:48 +0100 Subject: [PATCH 1/3] gettext: handle GIT_TEXTDOMAINDIR relative to $(prefix) On Windows, there is no single root directory. And what Git thinks is a root directory is not a root directory at all: everything is relative to the location where Git is installed. To handle this situation better, let's just allow for GIT_TEXTDOMAINDIR to be a path relative to the (runtime) prefix. To that end, we have to switch the order in which common-main handles argv0 and sets up gettext: in order to have access to the runtime prefix, we need it to be inferred from argv0 already. This patch also prepares for GIT_LOCALE_PATH to be relative to prefix, which is the even more important fix. Signed-off-by: Johannes Schindelin From 915f2efdf1511f3524b27c6526cd813d83f390f3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 14 Mar 2017 12:25:48 +0100 Subject: [PATCH 2/3] gettext: use a GIT_LOCALE_PATH relative to $(prefix) On Windows, we simply pass a POSIX path to bindtextdomain(), relying on the current libintl-8.dll implementation to handle that gracefully by resolving the path relative to the "root" directory inferred from the location of the .dll file itself. However, not only does this rely on the custom patches of the gettext library as shipped with MSYS2 (gettext's own source code is not prepared to handle POSIX paths on Windows), it also means that Git itself cannot use the `podir` variable at all because it does not handle absolute POSIX paths in system_path() correctly, leaving them as-is. This patch fixes that behavior by always using a GIT_LOCALE_PATH relative to the (runtime) prefix. Signed-off-by: Johannes Schindelin From 83214a7ba940d2f320cf0ebd719bc475c5269d27 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 14 Mar 2017 12:39:54 +0100 Subject: [PATCH 3/3] gettext: avoid initialization if the locale dir is not present The runtime of a simple `git.exe version` call on Windows is currently dominated by the gettext setup, adding a whopping ~150ms to the ~210ms total. Given that this cost is added to each and every git.exe invocation goes through common-main's invocation of git_setup_gettext(), and given that scripts have to call git.exe dozens, if not hundreds, of times, this is a substantial performance penalty. This is particularly pointless when considering that Git for Windows ships without localization (to keep the installer's size to a bearable ~34MB): all that time setting up gettext is for naught. So let's be smart about it and skip setting up gettext if the locale directory is not even present. Signed-off-by: Johannes Schindelin