aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Fontaine2015-11-23 15:03:12 +0100
committerBaptiste Fontaine2015-11-23 15:50:15 +0100
commite8c8b876af9f966a63c802b7fcbbe2c8fabebe48 (patch)
treeb12787c9933bd44a238ae8605a2e3da931fe2b8f
parentcd267e0bce9ca9cc1af37deab96c47e1cfb7645c (diff)
downloadbrew-e8c8b876af9f966a63c802b7fcbbe2c8fabebe48.tar.bz2
brew-log: warn if shallow clone
Closes Homebrew/homebrew#46283. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
-rw-r--r--Library/Homebrew/cmd/log.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb
index 6ffeab1e4..7f9dac40f 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