Skip to content

Commit

Permalink
tg-push.sh: handle explicit HEAD argument better
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle J. McKay <[email protected]>
  • Loading branch information
mackyle committed Nov 17, 2015
1 parent da1173a commit c44c886
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tg-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ if [ -z "$branches" ]; then
else
branches="$(verify_topgit_branch HEAD)"
fi
else
oldbranches="$branches"
branches=
for name in $oldbranches; do
if [ "$name" = "HEAD" ]; then
sr="$(git symbolic-ref --quiet HEAD || :)"
[ -n "$sr" ] || die "cannot push a detached HEAD"
case "$sr" in refs/heads/*) :;; *)
die "HEAD is a symref to other than refs/heads/..."
esac
branches="${branches:+$branches }${sr#refs/heads/}"
else
ref_exists "refs/heads/$name" || die "no such ref: refs/heads/$name"
branches="${branches:+$branches }$name"
fi
done
unset oldbranches
fi

for name in $branches; do
ref_exists "refs/heads/$name" || die "detached HEAD? Can't push $name"
done

_listfile="$(get_temp tg-push-listfile)"

push_branch()
Expand Down

0 comments on commit c44c886

Please sign in to comment.