-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getgit: flag for installation without modifying the environment #548
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ function usage(){ | |
echo " -k keep all downloaded, extracted files in \"/tmp\"" | ||
echo " -s skip downloading" | ||
echo " -f forcibly update no matter what version it is" | ||
echo " -e don't modify the environment (no /cmd in path, /etc/profile.d)" | ||
echo " -h this prints me..." | ||
exit | ||
} | ||
|
@@ -108,6 +109,8 @@ until [ $# -eq 0 ]; do | |
force_update=1; shift;; | ||
-s) | ||
skip_download=1; shift;; | ||
-e) | ||
no_env=1; shift;; | ||
-h) | ||
usage; shift;; | ||
*) | ||
|
@@ -188,72 +191,79 @@ process "/mingw$bit/share/git-core" | |
process "/mingw$bit/share/git-gui" | ||
process -f "/mingw$bit/share/perl5" | ||
process -f "/mingw$bit/ssl" | ||
process "/cmd" | ||
process -f "/etc/profile.d" | ||
if [[ ! x$no_env == x1 ]]; then | ||
process "/cmd" | ||
process -f "/etc/profile.d" | ||
else | ||
cp -f $gitupk/cmd/* $bin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to copy these files to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I understand the various tools only care about finding each other in $PATH, so it works in /cmd, /usr/bin, etc. I think it already breaks msys2/cygwin git due to copying files into /lib, but I'm not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most files in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. Would the PR be acceptable if /cmd is left as is (and not copied to somewhere else) i.e. only skips /etc/profile.d, the registry PATH setting, and the context menu scripts? I can add a message informing the user they need to add /cmd to path themselves. |
||
fi | ||
cp -f $gitupk/usr/bin/git* $bin | ||
|
||
echo "" | ||
# Generating scripts | ||
ctxmenu=/cmd/ctxmenu.bat | ||
echo '@echo off' > $ctxmenu | ||
echo '' >> $ctxmenu | ||
echo 'set /p=Adding "Git GUI Here" ... <nul' >> $ctxmenu | ||
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f /ve /d "Git &GUI Here"' >> $ctxmenu | ||
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 | ||
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; 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 -c '\ | ||
'\"cd '"'%%v'; export CHERE_INVOKING=1; export PATH=/mingw$bit/bin:\$PATH; exec /bin/bash --login -i"'\""' >> $ctxmenu | ||
fi | ||
echo '' >> $ctxmenu | ||
echo 'pause' >> $ctxmenu | ||
chmod +x $ctxmenu | ||
echo "A batch script by which the \"Git GUI Here\" and \"Git Bash Here\" could " | ||
echo "be added to the context menu is available as $ctxmenu " | ||
if [[ ! x$no_env == x1 ]]; then | ||
echo "" | ||
# Generating scripts | ||
ctxmenu=/cmd/ctxmenu.bat | ||
echo '@echo off' > $ctxmenu | ||
echo '' >> $ctxmenu | ||
echo 'set /p=Adding "Git GUI Here" ... <nul' >> $ctxmenu | ||
echo 'reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f /ve /d "Git &GUI Here"' >> $ctxmenu | ||
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 | ||
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; 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 -c '\ | ||
'\"cd '"'%%v'; export CHERE_INVOKING=1; export PATH=/mingw$bit/bin:\$PATH; exec /bin/bash --login -i"'\""' >> $ctxmenu | ||
fi | ||
echo '' >> $ctxmenu | ||
echo 'pause' >> $ctxmenu | ||
chmod +x $ctxmenu | ||
echo "A batch script by which the \"Git GUI Here\" and \"Git Bash Here\" could " | ||
echo "be added to the context menu is available as $ctxmenu " | ||
|
||
echo "" | ||
rm_ctxmenu=/cmd/rm-ctxmenu.bat | ||
echo '@echo off' > $rm_ctxmenu | ||
echo '' >> $rm_ctxmenu | ||
echo 'set /p=Deleting "Git GUI Here" ... <nul' >> $rm_ctxmenu | ||
echo 'reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f' >> $rm_ctxmenu | ||
echo 'set /p=Deleting "Git Bash Here" ... <nul' >> $rm_ctxmenu | ||
echo 'reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell" /f' >> $rm_ctxmenu | ||
echo 'pause' >> $rm_ctxmenu | ||
echo '' >> $rm_ctxmenu | ||
chmod +x $rm_ctxmenu | ||
echo "A batch script by which the \"Git GUI Here\" and \"Git Bash Here\" could " | ||
echo "be removed from the context menu is available as $rm_ctxmenu " | ||
echo "" | ||
rm_ctxmenu=/cmd/rm-ctxmenu.bat | ||
echo '@echo off' > $rm_ctxmenu | ||
echo '' >> $rm_ctxmenu | ||
echo 'set /p=Deleting "Git GUI Here" ... <nul' >> $rm_ctxmenu | ||
echo 'reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui" /f' >> $rm_ctxmenu | ||
echo 'set /p=Deleting "Git Bash Here" ... <nul' >> $rm_ctxmenu | ||
echo 'reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell" /f' >> $rm_ctxmenu | ||
echo 'pause' >> $rm_ctxmenu | ||
echo '' >> $rm_ctxmenu | ||
chmod +x $rm_ctxmenu | ||
echo "A batch script by which the \"Git GUI Here\" and \"Git Bash Here\" could " | ||
echo "be removed from the context menu is available as $rm_ctxmenu " | ||
|
||
echo "" | ||
# Setting ENV | ||
echo -n "Setting env ..." | ||
userpath=$(reg query "HKEY_CURRENT_USER\Environment" //v Path 2>/dev/null | awk 'NR==3 {print $NF}') | ||
if [[ "$userpath" == "" ]]; then | ||
setx PATH "$(cygpath -m /cmd)" > /dev/null 2>&1 | ||
elif [[ "$userpath" != *"$(cygpath -m /cmd)"* ]]; then | ||
setx PATH "$(cygpath -m /cmd);$userpath" > /dev/null 2>&1 | ||
echo "" | ||
# Setting ENV | ||
echo -n "Setting env ..." | ||
userpath=$(reg query "HKEY_CURRENT_USER\Environment" //v Path 2>/dev/null | awk 'NR==3 {print $NF}') | ||
if [[ "$userpath" == "" ]]; then | ||
setx PATH "$(cygpath -m /cmd)" > /dev/null 2>&1 | ||
elif [[ "$userpath" != *"$(cygpath -m /cmd)"* ]]; then | ||
setx PATH "$(cygpath -m /cmd);$userpath" > /dev/null 2>&1 | ||
fi | ||
fi | ||
|
||
echo done | ||
|
||
echo "" | ||
|
@@ -274,4 +284,4 @@ fi | |
echo "Git is now available! If you want to add \"Git GUI Here\" and \"Git Bash" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These messsges should probably be modified if the context menu scripts aren't created. |
||
echo "Here\" to the context menu, please help yourself with it using the " | ||
echo "$ctxmenu script. If you want to use \"git svn\", please install" | ||
echo "perl and subversion via $install_via_this" | ||
echo "perl and subversion via $install_via_this" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"no /cmd in path" sounds like that part is only about not modifying
$PATH
, whereas the code doesn't create/cmd
at all.