mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-30 00:04:03 +00:00
blob: fix fromchunks iteration counter
By returning when the count goes to zero rather than below it, setting `howmany` to 7 in fact writes out the string 6 times. Correct the termination condition to write out the string the amount of times we specify.
This commit is contained in:
parent
0a5c602889
commit
35e68606da
@ -26,7 +26,7 @@ static int text_chunked_source_cb(char *content, size_t max_length, void *payloa
|
|||||||
count = (int *)payload;
|
count = (int *)payload;
|
||||||
(*count)--;
|
(*count)--;
|
||||||
|
|
||||||
if (*count == 0)
|
if (*count < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
strcpy(content, textual_content);
|
strcpy(content, textual_content);
|
||||||
@ -37,7 +37,7 @@ void test_object_blob_fromchunks__can_create_a_blob_from_a_in_memory_chunk_provi
|
|||||||
{
|
{
|
||||||
git_oid expected_oid, oid;
|
git_oid expected_oid, oid;
|
||||||
git_object *blob;
|
git_object *blob;
|
||||||
int howmany = 7;
|
int howmany = 6;
|
||||||
|
|
||||||
cl_git_pass(git_oid_fromstr(&expected_oid, "321cbdf08803c744082332332838df6bd160f8f9"));
|
cl_git_pass(git_oid_fromstr(&expected_oid, "321cbdf08803c744082332332838df6bd160f8f9"));
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ void test_object_blob_fromchunks__doesnot_overwrite_an_already_existing_object(v
|
|||||||
git_buf path = GIT_BUF_INIT;
|
git_buf path = GIT_BUF_INIT;
|
||||||
git_buf content = GIT_BUF_INIT;
|
git_buf content = GIT_BUF_INIT;
|
||||||
git_oid expected_oid, oid;
|
git_oid expected_oid, oid;
|
||||||
int howmany = 7;
|
int howmany = 6;
|
||||||
|
|
||||||
cl_git_pass(git_oid_fromstr(&expected_oid, "321cbdf08803c744082332332838df6bd160f8f9"));
|
cl_git_pass(git_oid_fromstr(&expected_oid, "321cbdf08803c744082332332838df6bd160f8f9"));
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ static void write_attributes(git_repository *repo)
|
|||||||
static void assert_named_chunked_blob(const char *expected_sha, const char *fake_name)
|
static void assert_named_chunked_blob(const char *expected_sha, const char *fake_name)
|
||||||
{
|
{
|
||||||
git_oid expected_oid, oid;
|
git_oid expected_oid, oid;
|
||||||
int howmany = 7;
|
int howmany = 6;
|
||||||
|
|
||||||
cl_git_pass(git_oid_fromstr(&expected_oid, expected_sha));
|
cl_git_pass(git_oid_fromstr(&expected_oid, expected_sha));
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ void test_object_blob_fromstream__multiple_write(void)
|
|||||||
for (i = 0; i < howmany; i++)
|
for (i = 0; i < howmany; i++)
|
||||||
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
|
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
|
||||||
|
|
||||||
cl_git_pass(git_blob_create_fromstream_end(&id, stream));
|
cl_git_pass(git_blob_create_fromstream_commit(&id, stream));
|
||||||
cl_assert_equal_oid(&expected_id, &id);
|
cl_assert_equal_oid(&expected_id, &id);
|
||||||
|
|
||||||
cl_git_pass(git_object_lookup(&blob, repo, &expected_id, GIT_OBJ_BLOB));
|
cl_git_pass(git_object_lookup(&blob, repo, &expected_id, GIT_OBJ_BLOB));
|
||||||
@ -88,7 +88,7 @@ static void assert_named_chunked_blob(const char *expected_sha, const char *fake
|
|||||||
for (i = 0; i < howmany; i++)
|
for (i = 0; i < howmany; i++)
|
||||||
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
|
cl_git_pass(stream->write(stream, textual_content, strlen(textual_content)));
|
||||||
|
|
||||||
cl_git_pass(git_blob_create_fromstream_end(&id, stream));
|
cl_git_pass(git_blob_create_fromstream_commit(&id, stream));
|
||||||
|
|
||||||
cl_assert_equal_oid(&expected_id, &id);
|
cl_assert_equal_oid(&expected_id, &id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user