mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-22 18:37:52 +00:00
remote: don't check for upstream on an anonymous remote
If the remote is anonymous, then we cannot check for any configuration, as there is no name. Check for this before we try to use the name, which may be a NULL pointer. This fixes #2697.
This commit is contained in:
parent
e235db0212
commit
64fdd86d0e
@ -959,6 +959,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((!git_reference__is_branch(ref_name)) ||
|
if ((!git_reference__is_branch(ref_name)) ||
|
||||||
|
!git_remote_name(remote) ||
|
||||||
(error = git_branch_upstream_remote(&upstream_remote, repo, ref_name)) ||
|
(error = git_branch_upstream_remote(&upstream_remote, repo, ref_name)) ||
|
||||||
git__strcmp(git_remote_name(remote), git_buf_cstr(&upstream_remote)) ||
|
git__strcmp(git_remote_name(remote), git_buf_cstr(&upstream_remote)) ||
|
||||||
(error = git_branch_upstream_name(&upstream_name, repo, ref_name)) < 0 ||
|
(error = git_branch_upstream_name(&upstream_name, repo, ref_name)) < 0 ||
|
||||||
|
@ -535,6 +535,16 @@ static int remote_single_branch(git_remote **out, git_repository *repo, const ch
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_network_remote_remotes__fetch_from_anonymous(void)
|
||||||
|
{
|
||||||
|
git_remote *remote;
|
||||||
|
|
||||||
|
cl_git_pass(git_remote_create_anonymous(&remote, _repo, cl_fixture("testrepo.git"),
|
||||||
|
"refs/heads/*:refs/other/*"));
|
||||||
|
cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
|
||||||
|
git_remote_free(remote);
|
||||||
|
}
|
||||||
|
|
||||||
void test_network_remote_remotes__single_branch(void)
|
void test_network_remote_remotes__single_branch(void)
|
||||||
{
|
{
|
||||||
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
|
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user