aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorXu Cheng2016-07-14 15:39:05 +0800
committerGitHub2016-07-14 15:39:05 +0800
commit43a962a5cdb3ad6d9ffca0c37d73da6553d0f6b6 (patch)
tree3f9b8506766c73d38996b9e1b6773af72cf711c3 /Library/Homebrew/cmd
parent0ed673abdb59e2f75f9b8539cce318607924e87f (diff)
downloadbrew-43a962a5cdb3ad6d9ffca0c37d73da6553d0f6b6.tar.bz2
update: git init for core tap as well (#510)
A temporary measure before we decide whether vendor git or not.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/update.sh34
1 files changed, 28 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index 6423a028c..e6ba3d1ee 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -22,22 +22,42 @@ git() {
git_init_if_necessary() {
if [[ -n "$HOMEBREW_OSX" ]]
then
- OFFICIAL_REMOTE="https://github.com/Homebrew/brew.git"
+ BREW_OFFICIAL_REMOTE="https://github.com/Homebrew/brew"
+ CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/homebrew-core"
else
- OFFICIAL_REMOTE="https://github.com/Linuxbrew/brew.git"
+ BREW_OFFICIAL_REMOTE="https://github.com/Linuxbrew/brew"
+ CORE_OFFICIAL_REMOTE="https://github.com/Linuxbrew/homebrew-core"
fi
+ safe_cd "$HOMEBREW_REPOSITORY"
if [[ ! -d ".git" ]]
then
set -e
trap '{ rm -rf .git; exit 1; }' EXIT
git init
git config --bool core.autocrlf false
- git config remote.origin.url "$OFFICIAL_REMOTE"
+ git config remote.origin.url "$BREW_OFFICIAL_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
git reset --hard origin/master
- SKIP_FETCH_HOMEBREW_REPOSITORY=1
+ SKIP_FETCH_BREW_REPOSITORY=1
+ set +e
+ trap - EXIT
+ fi
+
+ [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || return
+ safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core"
+ if [[ ! -d ".git" ]]
+ then
+ set -e
+ trap '{ rm -rf .git; exit 1; }' EXIT
+ git init
+ git config --bool core.autocrlf false
+ git config remote.origin.url "$CORE_OFFICIAL_REMOTE"
+ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
+ git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
+ git reset --hard origin/master
+ SKIP_FETCH_CORE_REPOSITORY=1
set +e
trap - EXIT
fi
@@ -339,12 +359,13 @@ EOS
# only allow one instance of brew update
lock update
- safe_cd "$HOMEBREW_REPOSITORY"
git_init_if_necessary
# rename Taps directories
# this procedure will be removed in the future if it seems unnecessary
rename_taps_dir_if_necessary
+ safe_cd "$HOMEBREW_REPOSITORY"
+
# kill all of subprocess on interrupt
trap '{ pkill -P $$; wait; exit 130; }' SIGINT
@@ -354,7 +375,8 @@ EOS
for DIR in "$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*
do
[[ -d "$DIR/.git" ]] || continue
- [[ -n "$SKIP_FETCH_HOMEBREW_REPOSITORY" && "$DIR" = "$HOMEBREW_REPOSITORY" ]] && continue
+ [[ -n "$SKIP_FETCH_BREW_REPOSITORY" && "$DIR" = "$HOMEBREW_REPOSITORY" ]] && continue
+ [[ -n "$SKIP_FETCH_CORE_REPOSITORY" && "$DIR" = "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && continue
cd "$DIR" || continue
UPSTREAM_BRANCH="$(upstream_branch)"
# the refspec ensures that the default upstream branch gets updated