aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-08-12 01:15:14 -0500
committerJack Nagel2014-08-12 01:15:14 -0500
commit5cd6b3580a4d7227a42c8608fcc0955cab882b01 (patch)
treeaadea76dba1c3960ead6b2b2c1e873bb1d23036d
parentb8ba5c4d7e423e271c83cabb7cebd8ce7ec458f9 (diff)
downloadhomebrew-5cd6b3580a4d7227a42c8608fcc0955cab882b01.tar.bz2
Be robust against existing remote.origin config
I will take this opportunity to opine and say that I don't think sharing remote config settings across repositories makes sense. Remotes belong to the repository, and the URL has to be configured anyway. It breaks the assumption that you can run "git remote add origin" in a blank repo. Repository templates are a much nicer way to address any perceived duplication. Nonetheless, git allows this to happen and there are a number of misguided blogposts advocating it, so we should be robust against it. Closes #31107.
-rwxr-xr-xinstall9
1 files changed, 7 insertions, 2 deletions
diff --git a/install b/install
index 994d09d34..9aaac513c 100755
--- a/install
+++ b/install
@@ -4,6 +4,7 @@
# change the value of HOMEBREW_PREFIX.
HOMEBREW_PREFIX = '/usr/local'
HOMEBREW_CACHE = '/Library/Caches/Homebrew'
+HOMEBREW_REPO = 'https://github.com/Homebrew/homebrew'
module Tty extend self
def blue; bold 34; end
@@ -172,7 +173,11 @@ Dir.chdir HOMEBREW_PREFIX do
if git
# we do it in four steps to avoid merge errors when reinstalling
system git, "init", "-q"
- system git, "remote", "add", "origin", "https://github.com/Homebrew/homebrew"
+
+ # "git remote add origin" may fail if there is an origin remote defined in
+ # the user's global gitconfig
+ Kernel.system(git, "remote", "add", "origin", HOMEBREW_REPO) ||
+ system(git, "remote", "set-url", "--add", "origin", HOMEBREW_REPO)
args = git, "fetch", "origin", "master:refs/remotes/origin/master", "-n"
args << "--depth=1" if ARGV.include? "--fast"
@@ -185,7 +190,7 @@ Dir.chdir HOMEBREW_PREFIX do
# we use -k for curl because Leopard has a bunch of bad SSL certificates
curl_flags = "fsSL"
curl_flags << "k" if macos_version <= "10.5"
- system "/bin/bash -o pipefail -c '/usr/bin/curl -#{curl_flags} https://github.com/Homebrew/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'"
+ system "/bin/bash -o pipefail -c '/usr/bin/curl -#{curl_flags} #{HOMEBREW_REPO}/tarball/master | /usr/bin/tar xz -m --strip 1'"
end
end