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.
This commit is contained in:
Edward Thomson
2022-08-21 21:55:25 -04:00
parent ed27768458
commit c928d96ea4

View File

@@ -282,7 +282,11 @@ static int update_head_to_branch(
reflog_message)) < 0)
goto cleanup;
if (git_remote__default_branch(&default_branch, remote) < 0)
retcode = git_remote__default_branch(&default_branch, remote);
if (retcode == GIT_ENOTFOUND)
retcode = 0;
else if (retcode)
goto cleanup;
if (!git_remote__matching_refspec(remote, git_str_cstr(&default_branch)))