Commit b401dc9e by Jacques Germishuys Committed by Vicent Marti

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

parent 7d729d0b
...@@ -691,6 +691,11 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote ...@@ -691,6 +691,11 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
{ {
assert(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); return remote->transport->ls(out, size, remote->transport);
} }
...@@ -1932,6 +1937,8 @@ int git_remote_default_branch(git_buf *out, git_remote *remote) ...@@ -1932,6 +1937,8 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
size_t heads_len, i; size_t heads_len, i;
int error; int error;
assert(out);
if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0) if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
return error; return error;
......
...@@ -55,6 +55,17 @@ void test_network_remote_local__retrieve_advertised_references(void) ...@@ -55,6 +55,17 @@ void test_network_remote_local__retrieve_advertised_references(void)
cl_assert_equal_i(refs_len, 28); 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) void test_network_remote_local__retrieve_advertised_references_after_disconnect(void)
{ {
const git_remote_head **refs; 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