Get the branch name
Given a reference object, this will check that it really is a branch (ie. it lives under "refs/heads/" or "refs/remotes/"), and return the branch part of it.
Pointer to the abbreviated reference name. Owned by ref, do not free.
0 on success; GIT_EINVALID if the reference isn't either a local or remote branch, otherwise an error code.