mirror of
https://github.com/git/git.git
synced 2026-01-31 21:09:39 +00:00
git-wrapper: optionally skip cd $HOME when configured via resources
We recently added the ability to configure copies of the Git wrapper to launch custom command-lines, configured via plain old Windows resources. The main user is Git for Windows' `git-bash.exe`, of course. When the user double-clicks the `git bash` icon, it makes sense to start the Bash in the user's home directory. Third-party software, such as TortoiseGit or GitHub for Windows, may want to start the Git Bash in another directory, though. Now, when third-party software wants to call Git, they already have to construct a command-line, and can easily pass a command-line option `--no-cd` (which this commit introduces), and since that option is not available when the user double-clicks an icon on the Desktop or in the Explorer, let's keep the default to switch to the home directory if the `--no-cd` flag was not passed along. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -163,7 +163,7 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
|
||||
|
||||
static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
|
||||
LPWSTR *prefix_args, int *prefix_args_len,
|
||||
int *is_git_command, int *start_in_home)
|
||||
int *is_git_command, int *start_in_home, int *skip_arguments)
|
||||
{
|
||||
int id, wargc;
|
||||
LPWSTR *wargv;
|
||||
@@ -252,7 +252,14 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
|
||||
*prefix_args_len = wcslen(buf);
|
||||
|
||||
*is_git_command = 0;
|
||||
*start_in_home = 1;
|
||||
wargv = CommandLineToArgvW(GetCommandLine(), &wargc);
|
||||
if (wargc < 2 || wcscmp(L"--no-cd", wargv[1]))
|
||||
*start_in_home = 1;
|
||||
else {
|
||||
*start_in_home = 0;
|
||||
*skip_arguments = 1;
|
||||
}
|
||||
LocalFree(wargv);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -278,7 +285,7 @@ int main(void)
|
||||
basename = exepath + wcslen(exepath) + 1;
|
||||
if (configure_via_resource(basename, exepath, exep,
|
||||
&prefix_args, &prefix_args_len,
|
||||
&is_git_command, &start_in_home)) {
|
||||
&is_git_command, &start_in_home, &skip_arguments)) {
|
||||
/* do nothing */
|
||||
}
|
||||
else if (!wcsncmp(basename, L"git-", 4)) {
|
||||
|
||||
Reference in New Issue
Block a user