From ea069936bfbe64f5c3efe80e84b10efef389d807 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 24 Aug 2016 14:49:31 +0100 Subject: [PATCH 1/2] Revert "update: make GIT_EXECUTABLE an absolute path." This reverts commit b6afa228f4974f4af1e8938911e35150aa2991c8 from #778. --- Library/Homebrew/cmd/update.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 7b57bde246..dbd1a4de83 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -17,10 +17,7 @@ source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh" git() { if [[ -z "$GIT_EXECUTABLE" ]] then - GIT_EXECUTABLE_RELATIVE="$("$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" --homebrew=print-path)" - GIT_EXECUTABLE_BASE="$(basename "$GIT_EXECUTABLE_RELATIVE")" - GIT_EXECUTABLE_DIR="$(cd "$(dirname "$GIT_EXECUTABLE_RELATIVE")" && pwd)" - GIT_EXECUTABLE="$GIT_EXECUTABLE_DIR/$GIT_EXECUTABLE_BASE" + GIT_EXECUTABLE="$("$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" --homebrew=print-path)" fi "$GIT_EXECUTABLE" "$@" } From 408ac6088f0cdb32c6c033df4f4c18b8ce7829c1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 24 Aug 2016 10:22:55 +0100 Subject: [PATCH 2/2] scm/git: make --homebrew=print-path absolute. This ensures that the output is always a fully-resolved path. --- Library/Homebrew/shims/scm/git | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/shims/scm/git b/Library/Homebrew/shims/scm/git index 2a95b01818..eedca486bc 100755 --- a/Library/Homebrew/shims/scm/git +++ b/Library/Homebrew/shims/scm/git @@ -9,15 +9,23 @@ quiet_safe_cd() { cd "$1" >/dev/null || { echo "Error: failed to cd to $1" >&2; exit 1; } } +absdir() { + quiet_safe_cd "${1%/*}/" && pwd -P +} + +dirbasepath() { + local dir="$1" + local base="${2##*/}" + echo "$dir/$base" +} + realpath() { local path="$1" local dir - local base local dest - dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)" - base="${path##*/}" - path="$dir/$base" + dir="$(absdir "$path")" + path="$(dirbasepath "$dir" "$path")" while [[ -L "$path" ]] do @@ -28,9 +36,8 @@ realpath() { else path="$dir/$dest" fi - dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)" - base="${path##*/}" - path="$dir/$base" + dir="$(absdir "$path")" + path="$(dirbasepath "$dir" "$path")" done echo "$path" @@ -58,7 +65,9 @@ safe_exec() { fi if [[ "$HOMEBREW" = "print-path" ]] then - echo "$arg0" + local dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)" + local path="$(dirbasepath "$dir" "$arg0")" + echo "$path" exit fi exec "$@"