From 9fd5a92ff6e7b5e99f253f6775fc90cb72300f73 Mon Sep 17 00:00:00 2001 From: Jack Haden-Enneking Date: Mon, 25 Jun 2018 23:36:12 -0700 Subject: [PATCH 1/3] 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 --- Library/Homebrew/brew.sh | 10 ++++++++++ Library/Homebrew/cmd/update.sh | 3 ++- Library/Homebrew/manpages/brew.1.md.erb | 4 ++++ docs/Manpage.md | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 984571de1f..5cf45e4c18 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -102,6 +102,7 @@ then if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100900" ]] then HOMEBREW_SYSTEM_GIT_TOO_OLD="1" + HOMEBREW_FORCE_BREWED_GIT="1" fi if [[ -z "$HOMEBREW_CACHE" ]] @@ -135,6 +136,15 @@ else HOMEBREW_CURL="curl" 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_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | awk '{print $1"/"$2}')" HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION" diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index d3dae2be31..10668d2596 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -384,7 +384,8 @@ EOS fi 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" ]] then # we cannot install brewed git if homebrew/core is unavailable. diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 100a69d297..902d6bde5b 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -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. + * `HOMEBREW_FORCE_BREWED_GIT`: + If set, Homebrew will use a Homebrew-installed `git` rather than the + system version. + * `HOMEBREW_GITHUB_API_TOKEN`: A personal access token for the GitHub API, which you can create at . If set, GitHub will allow you a diff --git a/docs/Manpage.md b/docs/Manpage.md index 4666a3999f..9bfc267717 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -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. + * `HOMEBREW_FORCE_BREWED_GIT`: + If set, Homebrew will use a Homebrew-installed `git` rather than the + system version. + * `HOMEBREW_GITHUB_API_TOKEN`: A personal access token for the GitHub API, which you can create at . If set, GitHub will allow you a From 596f29aa402539b9c99c92faeb08c6ca079d0448 Mon Sep 17 00:00:00 2001 From: Jack Haden-Enneking Date: Tue, 26 Jun 2018 08:58:04 -0700 Subject: [PATCH 2/3] Update manpages --- manpages/brew.1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manpages/brew.1 b/manpages/brew.1 index 01e4263ead..55740e1170 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1187,6 +1187,10 @@ When using Git, Homebrew will use \fBGIT\fR if set, a Homebrew\-built Git if ins Set this to force Homebrew to use a particular git binary\. . .TP +\fBHOMEBREW_FORCE_BREWED_GIT\fR +If set, Homebrew will use a Homebrew\-installed \fBgit\fR rather than the system version\. +. +.TP \fBHOMEBREW_GITHUB_API_TOKEN\fR A personal access token for the GitHub API, which you can create at \fIhttps://github\.com/settings/tokens\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\. . From e63feb79f9054c59cccb9ab4ce91a77d078cd349 Mon Sep 17 00:00:00 2001 From: Jack Haden-Enneking Date: Tue, 26 Jun 2018 11:14:32 -0700 Subject: [PATCH 3/3] Simplify check before git install No need to check for both variables, because they're always set together. Also, this harmonizes with the CURL equivalent just above. --- Library/Homebrew/cmd/update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 10668d2596..320df908bb 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -384,9 +384,8 @@ EOS fi if ! git --version &>/dev/null || - [[ ( -n "$HOMEBREW_SYSTEM_GIT_TOO_OLD" || - -n "$HOMEBREW_FORCE_BREWED_GIT" ) && - ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] + [[ -n "$HOMEBREW_FORCE_BREWED_GIT" && + ! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]] then # we cannot install brewed git if homebrew/core is unavailable. [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git