Merge pull request #8391 from Bo98/update-reset-multirelative

cmd/update-reset: fix handling of multiple relative directories
This commit is contained in:
Bo Anderson 2020-08-19 16:14:44 +01:00 committed by GitHub
commit d2f10b0c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,16 +35,15 @@ homebrew-update-reset() {
for DIR in "${REPOS[@]}"
do
[[ -d "$DIR/.git" ]] || continue
cd "$DIR" || continue
ohai "Fetching $DIR..."
git fetch --force --tags origin
git remote set-head origin --auto >/dev/null
git -C "$DIR" fetch --force --tags origin
git -C "$DIR" remote set-head origin --auto >/dev/null
echo
ohai "Resetting $DIR..."
head="$(git symbolic-ref refs/remotes/origin/HEAD)"
head="$(git -C "$DIR" symbolic-ref refs/remotes/origin/HEAD)"
head="${head#refs/remotes/origin/}"
git checkout --force -B "$head" origin/HEAD
git -C "$DIR" checkout --force -B "$head" origin/HEAD
echo
done
}