Retrieve the referenced HEAD for the worktree
pointer to the reference which will be retrieved
a repository object
name of the worktree to retrieve HEAD for
0 when successful, error-code otherwise