diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-08-21 21:55:25 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-09-16 12:12:27 -0400 |
commit | f36cbc0eb05df875403a9bc01cc11ff148842697 (patch) | |
tree | a54ac960d58e897b5c4e5e42e8ff7c1332f70e9e | |
parent | adc3465107b0a5bc74d5615041a3615f9cd20ff0 (diff) | |
download | libgit2-f36cbc0eb05df875403a9bc01cc11ff148842697.tar.gz |
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.
-rw-r--r-- | src/libgit2/clone.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c index 6b1306418..0d393eb85 100644 --- a/src/libgit2/clone.c +++ b/src/libgit2/clone.c @@ -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))) |