Never push "HEAD"; don't touch current branch

This commit is contained in:
Midgard 2022-05-21 01:43:42 +02:00
parent b911a03848
commit 655f5c2fb4
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -81,6 +81,7 @@ for branchspec in "${branches[@]}"; do
set $branchspec
leader_sha="$1"
branch="$2"
if [ "$branch" = HEAD ]; then continue; fi
for remote in "${followers[@]}"; do
echo
@ -90,7 +91,7 @@ for branchspec in "${branches[@]}"; do
if ! ref_exists "$follower_ref"; then
echo "Branch doesn't yet exist at remote, creating"
git reset --hard "$leader_sha" --
git checkout "$leader_sha" --
git push "$remote" "+HEAD:$branch" || { error "$remote $branch: failed to push"; continue; }
elif is_ref_at_sha "$follower_ref" "$leader_sha"; then
@ -98,7 +99,7 @@ for branchspec in "${branches[@]}"; do
else
echo "Branch exists at remote, updating"
git reset --hard "$follower_ref" --
git checkout "$follower_ref" --
git merge --ff-only "$leader_sha" || { error "$remote $branch: FF not possible"; continue; }
git push "$remote" "+HEAD:$branch" || { error "$remote $branch: failed to push"; continue; }
fi