Fix first brew update with Git 1.7.4+; Fixes Homebrew/homebrew#5128

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 Homebrew/homebrew#6017.
This commit is contained in:
Max Howell 2011-06-15 13:00:13 +01:00
parent 8c521ca3d0
commit 08f31bc573

View File

@ -13,7 +13,6 @@ end
class RefreshBrew class RefreshBrew
REPOSITORY_URL = "http://github.com/mxcl/homebrew.git" REPOSITORY_URL = "http://github.com/mxcl/homebrew.git"
INIT_COMMAND = "git init"
CHECKOUT_COMMAND = "git checkout -q master" CHECKOUT_COMMAND = "git checkout -q master"
UPDATE_COMMAND = "git pull #{REPOSITORY_URL} master" UPDATE_COMMAND = "git pull #{REPOSITORY_URL} master"
REVISION_COMMAND = "git rev-parse HEAD" REVISION_COMMAND = "git rev-parse HEAD"
@ -40,7 +39,14 @@ class RefreshBrew
safe_system CHECKOUT_COMMAND safe_system CHECKOUT_COMMAND
@initial_revision = read_revision @initial_revision = read_revision
else 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 end
execute(UPDATE_COMMAND) execute(UPDATE_COMMAND)
@current_revision = read_revision @current_revision = read_revision