diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index d60da9db99..6618819e64 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -59,7 +59,7 @@ HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbr HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION" if [[ -z "$HOMEBREW_VERSION" ]] then - HOMEBREW_VERSION=">=1.4.0 (shallow or no git repository)" + HOMEBREW_VERSION=">=1.7.1 (shallow or no git repository)" HOMEBREW_USER_AGENT_VERSION="1.X.Y" fi diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh index 5ba8ec9d82..31bf279706 100644 --- a/Library/Homebrew/cmd/update-reset.sh +++ b/Library/Homebrew/cmd/update-reset.sh @@ -33,7 +33,14 @@ EOS [[ -d "$DIR/.git" ]] || continue cd "$DIR" || continue echo "==> Fetching $DIR..." - git fetch --tags --force origin + + if [[ "$DIR" = "$HOMEBREW_REPOSITORY" ]]; then + latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" + git fetch --force origin --shallow-since="$latest_tag" + else + git fetch --force --tags origin + fi + echo echo "==> Resetting $DIR..." diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 320df908bb..6e68cdea8c 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -35,7 +35,8 @@ git_init_if_necessary() { git config --bool core.autocrlf false 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 + latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)" + git fetch --force origin --shallow-since="$latest_tag" git reset --hard origin/master SKIP_FETCH_BREW_REPOSITORY=1 set +e