Skip to content

Commit c928d96

Browse files
committed
clone: narrow success tests on HEAD-less remotes
Only allow the remote default branch checking to fail when the remote default branch doesn't exist (`git_remote__default_branch` returns `GIT_ENOTFOUND`). If there was any other type of error - for example, an allocation failure - we should not swallow that and continue to fail. This allows us to support the case when a remote has not advertised a HEAD -- this is possible, for example, when the remote has constrained the caller to a particular namespace. But other remote failures remain as failures.
1 parent ed27768 commit c928d96

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libgit2/clone.c

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

285-
if (git_remote__default_branch(&default_branch, remote) < 0)
285+
retcode = git_remote__default_branch(&default_branch, remote);
286+
287+
if (retcode == GIT_ENOTFOUND)
288+
retcode = 0;
289+
else if (retcode)
286290
goto cleanup;
287291

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

0 commit comments

Comments
 (0)