Skip to content

Commit 045da6f

Browse files
committed
git-wrapper: leave the working directory alone by default
The idea of `git-bash.exe` automatically running the Git Bash in the home directory was to support the start menu item `Git Bash` (which should not start in C:\Program Files\Git, but in $HOME), and to make that behavior consistent with double-clicking in `git-bash.exe` portable Git. However, it turns out that one of the main use cases of portable Git is to run the Git Bash in GitHub for Windows, and it should start in the top-level directory of a given project. Therefore, the concern to keep double-clicking `git-bash.exe` consistent with the start menu item was actually unfounded. As to the start menu item: it can easily be changed to launch `git-bash.exe` with a command-line option. So let's introduce the --cd-to-home option for that purpose. As a bonus, the Git wrapper can now also serve as a drop-in redirector /bin/bash.exe to provide backwards-compatibility of Git for Windows 2.x with 1.x: some 3rd-party software expects to find that executable there, and it also expects it to leave the working directory unchanged. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8934fc2 commit 045da6f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compat/win32/git-wrapper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
331331
*prefix_args_len = wcslen(buf2);
332332

333333
*is_git_command = 0;
334-
*working_directory = (LPWSTR) 1;
335334
wargv = CommandLineToArgvW(GetCommandLine(), &wargc);
336335
for (i = 1; i < wargc; i++) {
337336
if (!wcscmp(L"--no-cd", wargv[i]))
338337
*working_directory = NULL;
338+
else if (!wcscmp(L"--cd-to-home", wargv[i]))
339+
*working_directory = (LPWSTR) 1;
339340
else if (!wcsncmp(L"--cd=", wargv[i], 5))
340341
*working_directory = wcsdup(wargv[i] + 5);
341342
else if (!wcscmp(L"--minimal-search-path", wargv[i]))

0 commit comments

Comments
 (0)