Implement HOMEBREW_FORCE_BREWED_GIT

Because of this messing with the user's path:
https://github.com/Homebrew/brew/blob/
    efc02899c851c62c9ce0d15dea9a231575d7d774/bin/brew#L68
brew uses /usr/bin/git over brewed git, even when the former is
problematically old.
There may also be other reasons a user prefers to use brewed git.

There was already a HOMEBREW_FORCE_BREWED_CURL option and a
HOMEBREW_SYSTEM_CURL_TOO_OLD check to set it. This mostly copies those
to implement HOMEBREW_FORCE_BREWED_GIT & HOMEBREW_SYSTEM_GIT_TOO_OLD.

See also: https://github.com/Linuxbrew/brew/issues/736
This commit is contained in:
Jack Haden-Enneking 2018-06-25 23:36:12 -07:00
parent 7db0f97523
commit 9fd5a92ff6
4 changed files with 20 additions and 1 deletions

View File

@ -102,6 +102,7 @@ then
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100900" ]] if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100900" ]]
then then
HOMEBREW_SYSTEM_GIT_TOO_OLD="1" HOMEBREW_SYSTEM_GIT_TOO_OLD="1"
HOMEBREW_FORCE_BREWED_GIT="1"
fi fi
if [[ -z "$HOMEBREW_CACHE" ]] if [[ -z "$HOMEBREW_CACHE" ]]
@ -135,6 +136,15 @@ else
HOMEBREW_CURL="curl" HOMEBREW_CURL="curl"
fi fi
if [[ -n "$HOMEBREW_FORCE_BREWED_GIT" &&
-x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] &&
"$HOMEBREW_PREFIX/opt/git/bin/git" --version >/dev/null
then
HOMEBREW_GIT="$HOMEBREW_PREFIX/opt/git/bin/git"
else
HOMEBREW_GIT="git"
fi
HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_USER_AGENT_VERSION)" HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_USER_AGENT_VERSION)"
HOMEBREW_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | awk '{print $1"/"$2}')" HOMEBREW_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | awk '{print $1"/"$2}')"
HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION" HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION"

View File

@ -384,7 +384,8 @@ EOS
fi fi
if ! git --version &>/dev/null || if ! git --version &>/dev/null ||
[[ -n "$HOMEBREW_SYSTEM_GIT_TOO_OLD" && [[ ( -n "$HOMEBREW_SYSTEM_GIT_TOO_OLD" ||
-n "$HOMEBREW_FORCE_BREWED_GIT" ) &&
! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]]
then then
# we cannot install brewed git if homebrew/core is unavailable. # we cannot install brewed git if homebrew/core is unavailable.

View File

@ -184,6 +184,10 @@ Note that environment variables must have a value set to be detected. For exampl
Set this to force Homebrew to use a particular git binary. Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_FORCE_BREWED_GIT`:
If set, Homebrew will use a Homebrew-installed `git` rather than the
system version.
* `HOMEBREW_GITHUB_API_TOKEN`: * `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a <https://github.com/settings/tokens>. If set, GitHub will allow you a

View File

@ -1167,6 +1167,10 @@ Note that environment variables must have a value set to be detected. For exampl
Set this to force Homebrew to use a particular git binary. Set this to force Homebrew to use a particular git binary.
* `HOMEBREW_FORCE_BREWED_GIT`:
If set, Homebrew will use a Homebrew-installed `git` rather than the
system version.
* `HOMEBREW_GITHUB_API_TOKEN`: * `HOMEBREW_GITHUB_API_TOKEN`:
A personal access token for the GitHub API, which you can create at A personal access token for the GitHub API, which you can create at
<https://github.com/settings/tokens>. If set, GitHub will allow you a <https://github.com/settings/tokens>. If set, GitHub will allow you a