summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-07-29 20:24:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-07-29 20:24:59 -0700
commitbf80cb63a50e5a3959c7d149910bf0f6e1f2bd0a (patch)
treeaa86b704f0bc8e0385b2601278804c6051cac40b
parent22f382539d78f69aa91721ad62bbd7229750a043 (diff)
downloadlibgit2-bf80cb63a50e5a3959c7d149910bf0f6e1f2bd0a.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)))