aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/cmd/doctor.rb18
-rw-r--r--Library/Homebrew/utils/git.rb3
2 files changed, 7 insertions, 14 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 6e8dc8e9f..39d320302 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -59,14 +59,6 @@ class Checks
def inject_file_list(list, str)
list.inject(str) { |s, f| s << " #{f}\n" }
end
-
- # Git will always be on PATH because of the wrapper script in
- # Library/ENV/scm, so we check if there is a *real*
- # git here to avoid multiple warnings.
- def git?
- return @git if instance_variable_defined?(:@git)
- @git = system "git --version >/dev/null 2>&1"
- end
############# END HELPERS
# Sorry for the lack of an indent here, the diff would have been unreadable.
@@ -884,7 +876,7 @@ class Checks
end
def check_for_git
- if git?
+ if Utils.git_available?
__check_git_version
else <<-EOS.undent
Git could not be found in your PATH.
@@ -896,7 +888,7 @@ class Checks
end
def check_git_newline_settings
- return unless git?
+ return unless Utils.git_available?
autocrlf = `git config --get core.autocrlf`.chomp
@@ -914,7 +906,7 @@ class Checks
end
def check_git_origin
- return unless git? && (HOMEBREW_REPOSITORY/".git").exist?
+ return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist?
origin = Homebrew.git_origin
@@ -1026,7 +1018,7 @@ class Checks
end
def check_git_status
- return unless git?
+ return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd do
unless `git status --untracked-files=all --porcelain -- Library/Homebrew/ 2>/dev/null`.chomp.empty?
<<-EOS.undent_________________________________________________________72
@@ -1120,7 +1112,7 @@ class Checks
end
def check_for_outdated_homebrew
- return unless git?
+ return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd do
if File.directory? ".git"
local = `git rev-parse -q --verify refs/remotes/origin/master`.chomp
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index 774a0a65f..10dbc83c1 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -1,7 +1,8 @@
module Utils
def self.git_available?
return @git if instance_variable_defined?(:@git)
- git = which("git")
+ # check git in original path in case it's the wrapper script of Library/ENV/scm
+ git = which("git", ORIGINAL_PATHS.join(File::PATH_SEPARATOR))
# git isn't installed by older Xcodes
return @git = false if git.nil?
# /usr/bin/git is a popup stub when Xcode/CLT aren't installed, so bail out