Skip to content

Commit 33f8d98

Browse files
edit-git-bash: update LCID when updating resources
When this developer compiled `edit-git-bash.c` to an EXE, `edit-git-bash.exe` did not behave as expected. Two string tables appeared in the resources section of the resulting `git-bash.exe` executable. Furthermore, this did _not_ occur when installing Git for Windows 2.7.2 using the InnoSetup installer on a test VM. However, this developer did confirm a problem with this program. When installing Git for Windows 2.7.2 and choosing the Windows Command Console as the terminal emulator, the string resources for `git-bash.exe` were updated. In fact, all resources were wiped out of `git-bash.exe` and a new STRINGTABLE resource was created containing the command to execute to start the BASH shell in a Windows Command Console. Resources that were wiped out included the Git for Windows icons that are embedded in the `git-bash.dll` (the file size went from 137KB to 28KB). When this developer used the resulting EXE from compiling the original `edit-git-bash.c` on `git-bash.exe`, `git-bash.exe` now contained tow STRINGTABLE resources, each with ID 1. This was confusing. How can this be? It turns out, the original STRINGTABLE with ID 1 contained two strings with sub-IDs 0 and 1. The STRINGTABLE had a LCID 1033 (0x0409, i.e. en-US). The new STRINGTABLE, also having an ID of 1, contained only one string resource, the new command line that was to be executed to start `git-bash.exe` in a Windows Command Console. However, it's LCID was 1024 (0x400, LANG_NEUTRAL, SUBLANG_DEFAULT). Why does this matter? Because my computer is set to LCID 1033 (en-US), when `git-bash.exe` was executed, it used the original string resources and started the BASH in mintty, not the Windows Command Console. Furthermore, when looking at the embedded resources for the installation of Git for Windows 2.7.2 set to use the Windows Command Console for the BASH, it worked correctly even though the string resources were for LCID 1024 (the neutral locale). That's because there was only one STRINGTABLE, and the neutral locale is the fallback locale. Since a string table resource for LCID 1033 could not be found, the neutral resources were used, resulting in correct behavior. It appears something may have changed with this code which is not reflected in the repository, as this developer researched the commit history with respect to this file. In any case, in its current form, compiling this file would not result in correct behavior. This commit, then, changes the updating of the string resources in `git-bash.exe` such that the new string resources are written in LCID 1033, just as the original resources of `git-bash.exe` are. This will prevent additional string table resources (in different locales) from being created and ensure that the proper resources are updated, resulting in correct behavior.
1 parent 1add57d commit 33f8d98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

edit-git-bash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int edit_git_bash(LPWSTR git_bash_path, LPWSTR new_command_line)
6060
return 2;
6161

6262
if (!UpdateResource(handle, RT_STRING, MAKEINTRESOURCE(1),
63-
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
63+
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
6464
buffer, alloc))
6565
result = 3;
6666

0 commit comments

Comments
 (0)