diff options
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/pack/packbuilder.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c index 6dc1c76fe..764fba213 100644 --- a/tests-clar/pack/packbuilder.c +++ b/tests-clar/pack/packbuilder.c @@ -8,7 +8,7 @@ static git_repository *_repo; static git_revwalk *_revwalker; static git_packbuilder *_packbuilder; -static git_indexer *_indexer; +static git_indexer_stream *_indexer; static git_vector _commits; static int _commits_is_initialized; @@ -40,7 +40,7 @@ void test_pack_packbuilder__cleanup(void) git_revwalk_free(_revwalker); _revwalker = NULL; - git_indexer_free(_indexer); + git_indexer_stream_free(_indexer); _indexer = NULL; cl_git_sandbox_cleanup(); @@ -75,20 +75,29 @@ static void seed_packbuilder(void) } } +static int feed_indexer(void *ptr, size_t len, void *payload) +{ + git_transfer_progress *stats = (git_transfer_progress *)payload; + + return git_indexer_stream_add(_indexer, ptr, len, stats); +} + void test_pack_packbuilder__create_pack(void) { git_transfer_progress stats; - git_buf buf = GIT_BUF_INIT; + git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT; git_hash_ctx ctx; git_oid hash; char hex[41]; hex[40] = '\0'; seed_packbuilder(); - cl_git_pass(git_packbuilder_write(_packbuilder, "testpack.pack")); - cl_git_pass(git_indexer_new(&_indexer, "testpack.pack")); - cl_git_pass(git_indexer_run(_indexer, &stats)); - cl_git_pass(git_indexer_write(_indexer)); + cl_git_pass(git_indexer_stream_new(&_indexer, ".", NULL, NULL)); + cl_git_pass(git_packbuilder_foreach(_packbuilder, feed_indexer, &stats)); + cl_git_pass(git_indexer_stream_finalize(_indexer, &stats)); + + git_oid_fmt(hex, git_indexer_stream_hash(_indexer)); + git_buf_printf(&path, "pack-%s.pack", hex); /* * By default, packfiles are created with only one thread. @@ -104,13 +113,14 @@ void test_pack_packbuilder__create_pack(void) * */ - cl_git_pass(git_futils_readbuffer(&buf, "testpack.pack")); + cl_git_pass(git_futils_readbuffer(&buf, git_buf_cstr(&path))); cl_git_pass(git_hash_ctx_init(&ctx)); cl_git_pass(git_hash_update(&ctx, buf.ptr, buf.size)); cl_git_pass(git_hash_final(&hash, &ctx)); git_hash_ctx_cleanup(&ctx); + git_buf_free(&path); git_buf_free(&buf); git_oid_fmt(hex, &hash); |
