Rename GIT_DIR to FISH_BASE_DIR in git_version_gen.sh

$GIT_DIR is interpreted by git as an environment variable, pointing at the
.git directory. If git_version_gen.sh is run in an environment with an
exported GIT_DIR, it will re-export GIT_DIR to point at the fish source
directory. This will cause git operations to fail.

This could be reproduced as building fish as part of an interactive rebase
'exec' command. git_version_gen.sh would always fail!
This commit is contained in:
ridiculousfish 2019-12-16 19:13:32 -08:00
parent 8bf9f52461
commit 4f3b3f7d61

View file

@ -6,8 +6,8 @@
set -e
# Find the fish git directory as two levels up from script directory.
GIT_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
# Find the fish directory as two levels up from script directory.
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
DEF_VER=unknown
# First see if there is a version file (included in release tarballs),
@ -15,7 +15,7 @@ DEF_VER=unknown
if test -f version
then
VN=$(cat version) || VN="$DEF_VER"
elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then
elif ! VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
VN="$DEF_VER"
fi