Skip to content

Commit bf80cb6

Browse files
committed
Don't fail the whole clone if you can't find a default branch
In commit 6bb3587 ("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>
1 parent 22f3825 commit bf80cb6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libgit2/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int update_head_to_branch(
282282
reflog_message)) < 0)
283283
goto cleanup;
284284

285-
if ((retcode = git_remote__default_branch(&default_branch, remote)) < 0)
285+
if (git_remote__default_branch(&default_branch, remote) < 0)
286286
goto cleanup;
287287

288288
if (!git_remote__matching_refspec(remote, git_str_cstr(&default_branch)))

0 commit comments

Comments
 (0)