diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh index 2b8de794a87058335a1fdd5e54ae27baa7eca75b..70b197777488dc22e172f633b144ecff40744662 100644 --- a/Library/Homebrew/cmd/update-reset.sh +++ b/Library/Homebrew/cmd/update-reset.sh @@ -38,6 +38,7 @@ homebrew-update-reset() { cd "$DIR" || continue ohai "Fetching $DIR..." git fetch --force --tags origin + git remote set-head origin --auto >/dev/null echo ohai "Resetting $DIR..." diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 19ece3f2d034ce8ec2898761ed45aace7ba7ffc6..e44e852c4070dc2f821e11cdb7cf93b58bb9c1aa 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -38,6 +38,7 @@ git_init_if_necessary() { git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" git fetch --force origin --shallow-since="$latest_tag" + git remote set-head origin --auto >/dev/null git reset --hard origin/master SKIP_FETCH_BREW_REPOSITORY=1 set +e @@ -59,6 +60,7 @@ git_init_if_necessary() { git config remote.origin.url "$HOMEBREW_CORE_GIT_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 remote set-head origin --auto >/dev/null git reset --hard origin/master SKIP_FETCH_CORE_REPOSITORY=1 set +e @@ -84,6 +86,11 @@ upstream_branch() { local upstream_branch upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)" + if [[ -z "$upstream_branch" ]] + then + git remote set-head origin --auto >/dev/null + upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)" + fi upstream_branch="${upstream_branch#refs/remotes/origin/}" [[ -z "$upstream_branch" ]] && upstream_branch="master" echo "$upstream_branch"