+# If $branch is the name of a branch but it does not start with
+# 'refs/heads/', prepend 'refs/heads/', so that we can know later
+# whether we are tagging a branch or some other kind of committish
+case "$branch" in
+ refs/heads/*) ;;
+ *)
+ branchref="$(git for-each-ref --format='%(objectname)' \
+ '[r]efs/heads/$branch')"
+ if [ "x$branchref" != "x" ]; then
+ branch="refs/heads/$branch"
+ fi
+ ;;
+esac
+
+# If our tag will point at a branch, push that branch, and add its
+# pushRemote and remote to the things we'll check if the user didn't
+# supply a remote
+case "$branch" in
+ refs/heads/*)
+ b=${branch#refs/heads/}
+ push_branch+=("$b")
+ remoteconfigs+=( branch.$b.pushRemote branch.$b.remote )
+ ;;
+esac