Skip to content

Commit c947fbf

Browse files
authored
Fix handling sequences of libgit2 read calls (#183)
* Fix handling sequence of libgit2 read calls * Add test
1 parent e10933f commit c947fbf

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/wasm/stream.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,14 @@ static int read(wasm_http_stream* stream, read_buffer_t& read_buffer, bool is_re
337337
}
338338
else
339339
{
340-
if (stream->m_request_index != -1)
341-
{
342-
git_error_set(
343-
GIT_ERROR_HTTP,
344-
"read called with pending request to %s",
345-
stream->m_unconverted_url.c_str()
346-
);
347-
return -1;
348-
}
349-
350-
if (create_request(stream, stream->m_service.m_response_type.c_str()) < 0)
340+
if (stream->m_request_index == -1)
351341
{
352-
convert_js_to_git_error(stream);
353-
return -1;
342+
// Send http(s) request if have not already done so.
343+
if (create_request(stream, stream->m_service.m_response_type.c_str()) < 0)
344+
{
345+
convert_js_to_git_error(stream);
346+
return -1;
347+
}
354348
}
355349
}
356350

test/test_clone.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .conftest import GIT2CPP_TEST_WASM
66

7+
xsimd_url = "https://github.com/xtensor-stack/xsimd.git"
78
xtl_url = "https://github.com/xtensor-stack/xtl.git"
89

910

@@ -218,3 +219,13 @@ def test_clone_negative_timeout_ignored(git2cpp_path, tmp_path, run_in_tmp_path)
218219
"environment variable GIT_HTTP_TIMEOUT must be a positive number of seconds"
219220
in p_clone.stdout
220221
)
222+
223+
224+
def test_clone_large_repo(git2cpp_path, tmp_path, run_in_tmp_path):
225+
clone_cmd = [git2cpp_path, "clone", xsimd_url]
226+
p_clone = subprocess.run(clone_cmd, capture_output=True, cwd=tmp_path, text=True)
227+
assert p_clone.returncode == 0
228+
229+
assert (tmp_path / "xsimd").exists()
230+
assert (tmp_path / "xsimd/include").exists()
231+
assert (tmp_path / "xsimd/xsimdConfig.cmake.in").exists()

0 commit comments

Comments
 (0)