Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Fix first brew update with Git 1.7.4+; Fixes #5128
Browse files Browse the repository at this point in the history
Behaviour for git checkout was changed such that the update would fail because it refused to checkout files on to existing files in the working directory.

This was bad behaviour anyway, we should make efforts to keep any local modifications to the Homebrew checkout. Everything is neatly resolved if we just do a --soft reset.

Closes #6017.
  • Loading branch information
mxcl committed Jun 15, 2011
1 parent cae8f9e commit 8bec9b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Library/Homebrew/cmd/update.rb
Expand Up @@ -13,7 +13,6 @@ def update

class RefreshBrew
REPOSITORY_URL = "http://github.com/mxcl/homebrew.git"
INIT_COMMAND = "git init"
CHECKOUT_COMMAND = "git checkout -q master"
UPDATE_COMMAND = "git pull #{REPOSITORY_URL} master"
REVISION_COMMAND = "git rev-parse HEAD"
Expand All @@ -40,7 +39,14 @@ def update_from_masterbrew!
safe_system CHECKOUT_COMMAND
@initial_revision = read_revision
else
safe_system INIT_COMMAND
begin
safe_system "git init"
safe_system "git fetch #{REPOSITORY_URL}"
safe_system "git reset FETCH_HEAD"
rescue Exception
safe_system "rm -rf .git"
raise
end
end
execute(UPDATE_COMMAND)
@current_revision = read_revision
Expand Down

0 comments on commit 8bec9b1

Please sign in to comment.