#!/bin/bash
g() { git "$@"; }
err() { printf '%b\n' "$*" 1>&2; exit 1; }
+vr() { echo "$@"; "$@"; }
case $1 in
""|-*) ;;
;;
g-push)
# For the times when repo is being stupid, push directly to gerrit myself.
- exec git push origin HEAD:refs/for/master
+ if ! branch=$(g symbolic-ref -q HEAD) ; then
+ err "could not figure out active branch"
+ fi
+ branch=${branch#refs/heads/}
+ if ! remote_branch=$(g cfg --get "branch.${branch}.merge") ; then
+ err "could not figure out remote branch"
+ fi
+ remote_branch=${remote_branch#refs/heads/}
+
+ for remote in cros-internal cros origin ; do
+ if g cfg --get "remote.${remote}.url" >/dev/null ; then
+ vr git push ${remote} ${branch}:refs/for/${remote_branch}
+ exit $?
+ fi
+ done
+ err "could not figure out remote to push to"
;;
sync)
[[ $# -eq 0 ]] && set -- -j16