diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-07-29 20:24:59 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-07-29 20:24:59 -0700 |
commit | bf80cb63a50e5a3959c7d149910bf0f6e1f2bd0a (patch) | |
tree | aa86b704f0bc8e0385b2601278804c6051cac40b | |
parent | 22f382539d78f69aa91721ad62bbd7229750a043 (diff) | |
download | libgit2-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.c | 2 |
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))) |