aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2016-03-09 17:35:03 +0800
committerXu Cheng2016-03-09 17:38:46 +0800
commit865b788e96b1e9fb0573845b1634dcd8bcc58ff4 (patch)
tree87a4ccca606e3515cf69835f7eed036adc81d3c4 /Library
parentec2a3f979ee81e5ed5d5368a6addbe9b31eb3ece (diff)
downloadbrew-865b788e96b1e9fb0573845b1634dcd8bcc58ff4.tar.bz2
Revert "update: checkout branch unconditionally"
This reverts commit 0525c9eeea27eff1a6de05e7a01ec268ae07437b. Which breaks `brew update --rebase`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/update.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index 0c2faf448..07847a0ba 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -211,13 +211,16 @@ pull() {
STASHED="1"
fi
- # Recreate and check out `#{upstream_branch}` if unable to fast-forward
- # it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
- if git merge-base --is-ancestor "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" &>/dev/null
+ if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
then
- git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
- else
- git checkout --force -B "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
+ # Recreate and check out `#{upstream_branch}` if unable to fast-forward
+ # it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
+ if git merge-base --is-ancestor "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" &>/dev/null
+ then
+ git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
+ else
+ git checkout --force -B "$UPSTREAM_BRANCH" "origin/$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
+ fi
fi
INITIAL_REVISION="$(read_current_revision)"