Retrieve and resolve the reference pointed at by HEAD.
pointer to the reference which will be retrieved
a repository object
0 on success; error code otherwise