summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-07-29 20:24:59 -0700
committerEdward Thomson <ethomson@edwardthomson.com>2022-09-16 11:25:49 -0400
commitadc3465107b0a5bc74d5615041a3615f9cd20ff0 (patch)
treee48a6ecef850002aacd2a22a463d1afae0bc85a9
parent71071360e1d4cbf2b615c2f593f8d049606e6122 (diff)
downloadlibgit2-adc3465107b0a5bc74d5615041a3615f9cd20ff0.tar.gz
Don't fail the whole clone if you can't find a default branch
In commit 6bb358786 ("clone: set refs/remotes/origin/HEAD to default branch when branch is specified, attempt 2") libgit2 was changed to set the default remote branch when one was copied. But it makes update_head_to_branch() return an error if the origin doesn't even *have* a HEAD in the first place, since git_remote_default_branch() will fail. That's entirely wrong, and means that you cannot do "git_clone()" of a particular branch on a remote repository when that remote doesn't have a default branch at all. So don't set the error code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--src/libgit2/clone.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c
index 1843875f8..6b1306418 100644
--- a/src/libgit2/clone.c
+++ b/src/libgit2/clone.c
@@ -282,7 +282,7 @@ static int update_head_to_branch(
reflog_message)) < 0)
goto cleanup;
- if ((retcode = git_remote__default_branch(&default_branch, remote)) < 0)
+ if (git_remote__default_branch(&default_branch, remote) < 0)
goto cleanup;
if (!git_remote__matching_refspec(remote, git_str_cstr(&default_branch)))