mirror of
https://github.com/git/git.git
synced 2026-02-01 21:40:11 +00:00
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 <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -331,11 +331,12 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
|
||||
*prefix_args_len = wcslen(buf2);
|
||||
|
||||
*is_git_command = 0;
|
||||
*working_directory = (LPWSTR) 1;
|
||||
wargv = CommandLineToArgvW(GetCommandLine(), &wargc);
|
||||
for (i = 1; i < wargc; i++) {
|
||||
if (!wcscmp(L"--no-cd", wargv[i]))
|
||||
*working_directory = NULL;
|
||||
else if (!wcscmp(L"--cd-to-home", wargv[i]))
|
||||
*working_directory = (LPWSTR) 1;
|
||||
else if (!wcsncmp(L"--cd=", wargv[i], 5))
|
||||
*working_directory = wcsdup(wargv[i] + 5);
|
||||
else if (!wcscmp(L"--minimal-search-path", wargv[i]))
|
||||
|
||||
Reference in New Issue
Block a user