From f31e411f386f3366696cb192c28cb95b33249f3d Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Tue, 30 Jun 2015 20:29:48 -0700 Subject: [PATCH] Git: unshallow shallow clones if necessary Fixes Homebrew/homebrew#41225. --- Library/Homebrew/download_strategy.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 597ab1ad9a..6ee032a716 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -582,6 +582,10 @@ class GitDownloadStrategy < VCSDownloadStrategy @shallow && support_depth? end + def is_shallow_clone? + git_dir.join("shallow").exist? + end + def support_depth? @ref_type != :revision && SHALLOW_CLONE_WHITELIST.any? { |rx| rx === @url } end @@ -632,7 +636,11 @@ class GitDownloadStrategy < VCSDownloadStrategy def update_repo if @ref_type == :branch || !has_ref? - quiet_safe_system 'git', 'fetch', 'origin' + if !shallow_clone? && is_shallow_clone? + quiet_safe_system 'git', 'fetch', 'origin', '--unshallow' + else + quiet_safe_system 'git', 'fetch', 'origin' + end end end