revparse: Introduce git_revparse_ext()

Expose a way to retrieve, along with the target git_object, the reference
pointed at by some revparse expression (`@{<-n>}` or
`<branchname>@{upstream}` syntax).
Fix some memory leaks
Fix "uninitialized variable" warning