doctor: be more robust about git status check

`git status -s` would spit out "fatal: not a git repository" when not in
HOMEBREW_PREFIX or a child directory of HOMEBREW_PREFIX. Specify a
git-dir and work-tree to fix this.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2011-09-11 11:06:00 -05:00
parent 536446b664
commit 627a8463a6

View File

@ -750,7 +750,8 @@ def check_missing_deps
end
def check_git_status
if system "/usr/bin/which -s git" and not `git status -s #{HOMEBREW_PREFIX}/Library/Homebrew`.empty?
status_cmd = "git --git-dir=#{HOMEBREW_REPOSITORY}/.git --work-tree=#{HOMEBREW_PREFIX} status -s #{HOMEBREW_PREFIX}/Library/Homebrew"
if system "/usr/bin/which -s git" and not `#{status_cmd}`.empty?
ohai "You have uncommitted modifications to Homebrew core"
puts "Unless you know what you are doing, you should: git reset --hard"
end