#!/bin/bash

# combo of git mysync and git pushall (except to the remote we just synced to,
# that would be unnecessary)

set -u

PATH=$PATH:$(dirname "$0")
which git-mysync >&/dev/null || { echo "git-mysync not found"; exit -1; }

branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_remote=$(git config --get branch.$branch_name.remote)
if git-mysync; then
    for r in $(git remote); do
        [[ $r = $branch_remote ]] || {
            echo "pushing $branch_name to $r"
            git push $r "$@"
        }
    done
fi

