subtree: don't fuss with PATH
Scripts needing to fuss with with adding $(git --exec-prefix) PATH before loading git-sh-setup is a thing of the past. As far as I can tell, it's been a thing of the past since since Git v1.2.0 (2006-02-12), or more specifically, since77cb17e940
(Exec git programs without using PATH, 2006-01-10). However, it stuck around in contrib scripts and in third-party scripts for long enough that it wasn't unusual to see. Originally `git subtree` didn't fuss with PATH, but when people (including the original subtree author) had problems, because it was a common thing to see, it seemed that having subtree fuss with PATH was a reasonable solution. Here is an abridged history of fussing with PATH in subtree:2987e6add3
(Add explicit path of git installation by 'git --exec-path', Gianluca Pacchiella, 2009-08-20) As pointed out by documentation, the correct use of 'git-sh-setup' is using $(git --exec-path) to avoid problems with not standard installations. -. git-sh-setup +. $(git --exec-path)/git-sh-setup33aaa697a2
(Improve patch to use git --exec-path: add to PATH instead, Avery Pennarun, 2009-08-26) If you (like me) are using a modified git straight out of its source directory (ie. without installing), then --exec-path isn't actually correct. Add it to the PATH instead, so if it is correct, it'll work, but if it's not, we fall back to the previous behaviour. -. $(git --exec-path)/git-sh-setup +PATH=$(git --exec-path):$PATH +. git-sh-setup9c632ea29c
((Hopefully) fix PATH setting for msysgit, Avery Pennarun, 2010-06-24) Reported by Evan Shaw. The problem is that $(git --exec-path) includes a 'git' binary which is incompatible with the one in /usr/bin; if you run it, it gives you an error about libiconv2.dll. +OPATH=$PATH PATH=$(git --exec-path):$PATH . git-sh-setup +PATH=$OPATH # apparently needed for some versions of msysgitdf2302d774
(Another fix for PATH and msysgit, Avery Pennarun, 2010-06-24) Evan Shaw tells me the previous fix didn't work. Let's use this one instead, which he says does work. This fix is kind of wrong because it will run the "correct" git-sh-setup *after* the one in /usr/bin, if there is one, which could be weird if you have multiple versions of git installed. But it works on my Linux and his msysgit, so it's obviously better than what we had before. -OPATH=$PATH -PATH=$(git --exec-path):$PATH +PATH=$PATH:$(git --exec-path) . git-sh-setup -PATH=$OPATH # apparently needed for some versions of msysgit First of all, I disagree with Gianluca's reading of the documentation: - I haven't gone back to read what the documentation said in 2009, but in my reading of the 2021 documentation is that it includes "$(git --exec-path)/" in the synopsis for illustrative purposes, not to say it's the proper way. - After being executed by `git`, the git exec path should be the very first entry in PATH, so it shouldn't matter. - None of the scripts that are part of git do it that way. But secondly, the root reason for fussing with PATH seems to be that Avery didn't know that he needs to set GIT_EXEC_PATH if he's going to use git from the source directory without installing. And finally, Evan's issue is clearly just a bug in msysgit. I assume that msysgit has since fixed the issue, and also msysgit has been deprecated for 6 years now, so let's drop the workaround for it. So, remove the line fussing with PATH. However, since subtree *is* in 'contrib/' and it might get installed in funny ways by users after-the-fact, add a sanity check to the top of the script, checking that it is installed correctly. Signed-off-by: Luke Shumaker <lukeshu@datawire.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
a94f911072
commit
22d5507493
@ -5,6 +5,22 @@
|
||||
# Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>
|
||||
#
|
||||
|
||||
if test -z "$GIT_EXEC_PATH" || test "${PATH#"${GIT_EXEC_PATH}:"}" = "$PATH" || ! test -f "$GIT_EXEC_PATH/git-sh-setup"
|
||||
then
|
||||
echo >&2 'It looks like either your git installation or your'
|
||||
echo >&2 'git-subtree installation is broken.'
|
||||
echo >&2
|
||||
echo >&2 "Tips:"
|
||||
echo >&2 " - If \`git --exec-path\` does not print the correct path to"
|
||||
echo >&2 " your git install directory, then set the GIT_EXEC_PATH"
|
||||
echo >&2 " environment variable to the correct directory."
|
||||
echo >&2 " - Make sure that your \`${0##*/}\` file is either in your"
|
||||
echo >&2 " PATH or in your git exec path (\`$(git --exec-path)\`)."
|
||||
echo >&2 " - You should run git-subtree as \`git ${0##*/git-}\`,"
|
||||
echo >&2 " not as \`${0##*/}\`." >&2
|
||||
exit 126
|
||||
fi
|
||||
|
||||
OPTS_SPEC="\
|
||||
git subtree add --prefix=<prefix> <commit>
|
||||
git subtree add --prefix=<prefix> <repository> <ref>
|
||||
@ -28,8 +44,6 @@ rejoin merge the new branch back into HEAD
|
||||
squash merge subtree changes as a single commit
|
||||
"
|
||||
|
||||
PATH=$PATH:$(git --exec-path)
|
||||
|
||||
arg_debug=
|
||||
arg_command=
|
||||
arg_prefix=
|
||||
|
Loading…
Reference in New Issue
Block a user