summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-08-10 17:50:46 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-08-29 15:28:10 +0200
commit0cdaa3766a772e65dcbc491a2d671b6169e97c60 (patch)
tree764f0dd15dbee2d589518124cdb84dbdd85d1a66
parent94412b009e81f0fdd474b0a0848f117cac3bd3b5 (diff)
downloadlibgit2-0cdaa3766a772e65dcbc491a2d671b6169e97c60.tar.gz
remote: short-circuit the default branch check if there is none
If we do not have a HEAD ref in the heads, we already know there is no default branch. Return immedately.
-rw-r--r--src/remote.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index 8d35fd69a..fa5ec8b4c 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1955,6 +1955,9 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
if (heads_len == 0)
return GIT_ENOTFOUND;
+ if (strcmp(heads[0]->name, GIT_HEAD_FILE))
+ return GIT_ENOTFOUND;
+
git_buf_sanitize(out);
/* the first one must be HEAD so if that has the symref info, we're done */
if (heads[0]->symref_target)