diff options
author | Edward Thomson <ethomson@github.com> | 2016-06-03 14:18:08 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-06-03 14:18:08 -0500 |
commit | 5afe1873488b43a0658bf3816565a19d075e0182 (patch) | |
tree | 2ea69b0b95c2fe4f642788e30045bb8aa98d3740 /src | |
parent | 0aaba445933bed0ab046009fe6c4aca1aaf7c6b9 (diff) | |
download | libgit2-ethomson/unborn_head.tar.gz |
repository_head: return HEAD when on unborn branchethomson/unborn_head
When we're on an unborn branch, correctly set the out param so that
callers can determine what the unborn branch is.
Diffstat (limited to 'src')
-rw-r--r-- | src/repository.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/repository.c b/src/repository.c index d39a9015d..8723e2fd0 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1747,10 +1747,16 @@ int git_repository_head(git_reference **head_out, git_repository *repo) return 0; } - error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1); - git_reference_free(head); + error = git_reference_lookup_resolved(head_out, + repo, git_reference_symbolic_target(head), -1); - return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error; + if (error == GIT_ENOTFOUND) { + *head_out = head; + return GIT_EUNBORNBRANCH; + } + + git_reference_free(head); + return error; } int git_repository_head_unborn(git_repository *repo) |