Skip to content

Commit

Permalink
git: remove LC_ALL magic from the git-wrapper
Browse files Browse the repository at this point in the history
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 git-for-windows/git#1036

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 21, 2017
1 parent 2c8ab4f commit c7a8a9a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions mingw-w64-git/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c7a8a9a

Please sign in to comment.