aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 8cb429da7..25320c004 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -322,6 +322,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
config_repo
update_repo
checkout
+ reset
update_submodules if submodules?
end
elsif @clone.exist?
@@ -339,10 +340,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
if @spec and @ref
ohai "Checking out #@spec #@ref"
else
- # otherwise the checkout-index won't checkout HEAD
- # https://github.com/mxcl/homebrew/issues/7124
- # must specify origin/HEAD, otherwise it resets to the current local HEAD
- quiet_safe_system @@git, "reset", { :quiet_flag => "-q" }, "--hard", "origin/HEAD"
+ reset
end
# http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
safe_system @@git, 'checkout-index', '-a', '-f', "--prefix=#{dst}/"
@@ -426,6 +424,22 @@ class GitDownloadStrategy < AbstractDownloadStrategy
nostdout { quiet_safe_system @@git, *checkout_args }
end
+ def reset_args
+ ref = case @spec
+ when :branch then "origin/#@ref"
+ when :revision, :tag then @ref
+ else "origin/HEAD"
+ end
+
+ args = %w{reset}
+ args << { :quiet_flag => "-q" }
+ args << "--hard" << ref
+ end
+
+ def reset
+ quiet_safe_system @@git, *reset_args
+ end
+
def update_submodules
safe_system @@git, 'submodule', 'update', '--init'
end