Skip to content

Commit

Permalink
Ensure the /cmd folder exists and sh could be found by `Git GUI H…
Browse files Browse the repository at this point in the history
…ere`

So that the generating feature won't fail when there's now /cmd folder
available, and fixes the `hook execution requires sh (not in PATH)`
error when using `Git GUI Here` on Cygwin whose default bin folder is
`/bin` rather than `/usr/bin`.

In addition:
There's a known issue that are hard to fix without breaking the
principle of `keeping every existing things intact`: the `Git Bash Here`
on Cygwin won't have a nice prompt which shows the current branch of
current directory. To fix this, the `/etc/bash.bashrc` needs be edited.

Signed-off-by: liuxy <[email protected]>
  • Loading branch information
sinloss committed Nov 4, 2019
1 parent a758b93 commit 1742a6b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions git-extra/getgit
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ until [ $# -eq 0 ]; do
done

gh_tags=https://gitforwindows.org/latest-tag.txt
[[ -e /bin ]] || mkdir /bin
[[ -e /cmd ]] || mkdir /cmd
[[ -e /tmp ]] || mkdir /tmp

echo ""
Expand Down Expand Up @@ -199,20 +199,28 @@ echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f /ve /d "
echo 'set /p=Adding icon for "Git GUI Here" ... <nul' >> $ctxmenu
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f /v Icon /d "%~dp0\git-gui.exe"' >> $ctxmenu
echo 'set /p=Adding command for "Git GUI Here" ... <nul' >> $ctxmenu
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui\command" /f /ve /d "\"%~dp0\git-gui.exe\" '\
'\"--working-dir\" \"%%v.\""' >> $ctxmenu
if [[ "$system" == "Msys" ]]; then
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui\command" '\
'/f /ve /d "\"%~dp0\git-gui.exe\" \"--working-dir\" \"%%v.\""' >> $ctxmenu
else # Cygwin
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui\command" '\
'/f /ve /d "cmd.exe /s /c \"set \"PATH=%~dp0\..\bin\" '\
'^&^& \"%~dp0\git-gui.exe\" \"--working-dir\" \"%%v.\"\""' >> $ctxmenu
fi
echo '' >> $ctxmenu
echo 'set /p=Adding "Git Bash Here" ... <nul' >> $ctxmenu
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell" /f /ve /d "Git Ba&sh Here"' >> $ctxmenu
echo 'set /p=Adding icon for "Git Bash Here" ... <nul' >> $ctxmenu
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell" /f /v Icon /d "%~dp0\git-gui.exe"' >> $ctxmenu
echo 'set /p=Adding command for "Git Bash Here" ... <nul' >> $ctxmenu
if [[ "$system" == "Msys" ]]; then
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command" /f /ve /d "\"%~dp0..\usr\bin\mintty.exe\" -i /cmd/git-gui.exe /usr/bin/bash -c '\
'\"cd '"'%%v'; export CHERE_INVOKING=1; exec /usr/bin/bash --login -i"'\""' >> $ctxmenu
else
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command" /f /ve /d "\"%~dp0..\bin\mintty.exe\" -i /cmd/git-gui.exe /bin/bash -c '\
'\"cd '"'%%v'; export CHERE_INVOKING=1; exec /bin/bash --login -i"'\""' >> $ctxmenu
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command" '\
'/f /ve /d "\"%~dp0..\usr\bin\mintty.exe\" -i /cmd/git-gui.exe /usr/bin/bash -c '\
'\"cd '"'%%v'; export CHERE_INVOKING=1; export MSYSTEM=MINGW$bit; exec /usr/bin/bash --login -i"'\""' >> $ctxmenu
else # Cygwin
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command" '\
'/f /ve /d "\"%~dp0..\bin\mintty.exe\" -i /cmd/git-gui.exe /bin/bash --login -i -c '\
'\"cd '"'%%v'; export CHERE_INVOKING=1; export PATH=/mingw$bit/bin:\$PATH; exec /bin/bash"'\""' >> $ctxmenu
fi
echo '' >> $ctxmenu
echo 'pause' >> $ctxmenu
Expand Down

0 comments on commit 1742a6b

Please sign in to comment.