From e8c8b876af9f966a63c802b7fcbbe2c8fabebe48 Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine Date: Mon, 23 Nov 2015 15:03:12 +0100 Subject: [PATCH] brew-log: warn if shallow clone Closes Homebrew/homebrew#46283. Signed-off-by: Baptiste Fontaine --- Library/Homebrew/cmd/log.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb index 6ffeab1e44..7f9dac40fb 100644 --- a/Library/Homebrew/cmd/log.rb +++ b/Library/Homebrew/cmd/log.rb @@ -4,11 +4,25 @@ module Homebrew def log if ARGV.named.empty? cd HOMEBREW_REPOSITORY - exec "git", "log", *ARGV.options_only + git_log else path = Formulary.path(ARGV.named.first) cd path.dirname # supports taps - exec "git", "log", *ARGV.options_only + ["--", path] + git_log path end end + + private + + def git_log(path=nil) + if File.exist? "#{`git rev-parse --show-toplevel`.chomp}/.git/shallow" + opoo <<-EOS.undent + The git repository is a shallow clone therefore the filtering may be incorrect. + Use `git fetch --unshallow` to get the full repository. + EOS + end + args = ARGV.options_only + args += ["--", path] unless path.nil? + exec "git", "log", *args + end end