Can we remove all this whatnot and replace it with `git_reference_shorthand` (https://github.com/libgit2/libgit2/blob/development/include/git2/refs.h#L540)?