Commit dc8adda4 by Jacques Germishuys

git_remote_ls() should return an error if the transport is not available

parent e1c44290
......@@ -699,6 +699,11 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
{
assert(remote);
if (!remote->transport) {
giterr_set(GITERR_NET, "No transport bound to this remote");
return -1;
}
return remote->transport->ls(out, size, remote->transport);
}
......@@ -1942,6 +1947,8 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
size_t heads_len, i;
int error;
assert(out);
if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
return error;
......
......@@ -55,6 +55,17 @@ void test_network_remote_local__retrieve_advertised_references(void)
cl_assert_equal_i(refs_len, 28);
}
void test_network_remote_local__retrieve_advertised_before_connect(void)
{
const git_remote_head **refs;
size_t refs_len = 0;
git_buf_sets(&file_path_buf, cl_git_path_url(cl_fixture("testrepo.git")));
cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
cl_git_fail(git_remote_ls(&refs, &refs_len, remote));
}
void test_network_remote_local__retrieve_advertised_references_after_disconnect(void)
{
const git_remote_head **refs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment