diff options
| author | Jack Nagel | 2013-02-17 15:53:34 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-02-17 15:53:35 -0600 |
| commit | 6d1c6dcdeae8eb90d5679faa53c82dcc1574d017 (patch) | |
| tree | 716e2c7a810883358327afff155f067bb1efcbaa /Library | |
| parent | 145647fc45fc5b9f3cf23a91c3b2b5f48789421a (diff) | |
| download | brew-6d1c6dcdeae8eb90d5679faa53c82dcc1574d017.tar.bz2 | |
GitDownloadStrategy: reset after checkout during updates
Otherwise, if the local branch is behind the remote branch, or has
diverged, we will stage the wrong revision.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 22 |
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 |
