git: fix #commit_pinning with tags

This fixes a failure in #commit_pinning, where update-ref gets called
with a tag instead of a commit by resolving the commit explicitely.
Moreover, it fixes the rescue clause to ensure that it does not
create a detached HEAD
git: make the tag ref unambiguous when calling #commit_pinning
git: fix checking out a package which is pinned to a tag or commit