From 0cdaa3766a772e65dcbc491a2d671b6169e97c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sun, 10 Aug 2014 17:50:46 +0200 Subject: [PATCH] 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. --- src/remote.c | 3 +++ 1 file changed, 3 insertions(+) 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)