Skip to content

Commit 9342731

Browse files
committed
installer: work around misquoting in Git Bash Here
When calling `Git Bash Here` from the background of the `C:\` directory in Windows Explorer, the term `%v` is expanded to the directory. To allow for spaces in the directory name, we quote that directory when passing the directory's path as `"--cd=%v"` parameter to `git-bash.exe`. Unfortunately, the `CommandLineToArgvW()` function mistakes the last part of `"--cd=C:\"` for a quoted double quote, and as a consequence `CreateProcess()` fails because there is no `C:"` directory. To work around this, let's just append `.`: this turns the parameter into `"--cd=C:\."` which is correctly interpreted as `C:\.` directory. It works also in the general case, where `%v` does *not* expand into a path with a trailing backslash because on Windows, `<name>` and `<name>.` refer to the same file. This fixes git-for-windows/git#176. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b727f38 commit 9342731

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

installer/install.iss.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ begin
15111511
Cmd:='"'+AppDir+'\git-bash.exe" "--cd=%1"';
15121512
if (not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_shell','',Msg)) or
15131513
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_shell\command','',Cmd)) or
1514-
(StringChangeEx(Cmd,'%1','%v',false)<>1) or
1514+
(StringChangeEx(Cmd,'%1','%v.',false)<>1) or
15151515
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\Background\shell\git_shell','',Msg)) or
15161516
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\Background\shell\git_shell\command','',Cmd)) then
15171517
begin
@@ -1528,7 +1528,7 @@ begin
15281528
Cmd:='"'+AppDir+'\cmd\git-gui.exe" "--working-dir" "%1"';
15291529
if (not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_gui','',Msg)) or
15301530
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_gui\command','',Cmd)) or
1531-
(StringChangeEx(Cmd,'%1','%v',false)<>1) or
1531+
(StringChangeEx(Cmd,'%1','%v.',false)<>1) or
15321532
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\Background\shell\git_gui','',Msg)) or
15331533
(not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\Background\shell\git_gui\command','',Cmd))
15341534
then begin

0 commit comments

Comments
 (0)