diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2012-10-31 13:26:04 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2012-11-01 09:21:49 +0400 |
commit | 3dfed9cb86a54bc8266057ef62b99f5d889f4efc (patch) | |
tree | b3fbe62f550fb1224404fe18bd5524f20eb7760d /tests-clar/pack | |
parent | efde422553e1181933d0bc9d7112740e858a847b (diff) |
packbuilder: add git_packbuilder_foreach
Let the user get each object as a buffer+size pair so they can handle
the packfile content as they need to.
Diffstat (limited to 'tests-clar/pack')
-rw-r--r-- | tests-clar/pack/packbuilder.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c index 6d17a709f..208141c27 100644 --- a/tests-clar/pack/packbuilder.c +++ b/tests-clar/pack/packbuilder.c @@ -28,12 +28,12 @@ void test_pack_packbuilder__cleanup(void) git_packbuilder_free(_packbuilder); git_revwalk_free(_revwalker); git_indexer_free(_indexer); + _indexer = NULL; git_repository_free(_repo); } -void test_pack_packbuilder__create_pack(void) +static void seed_packbuilder(void) { - git_transfer_progress stats; git_oid oid, *o; unsigned int i; @@ -58,10 +58,37 @@ void test_pack_packbuilder__create_pack(void) git_commit_tree_oid((git_commit *)obj))); git_object_free(obj); } +} + +void test_pack_packbuilder__create_pack(void) +{ + git_transfer_progress stats; + 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)); } + +static git_transfer_progress stats; +static int foreach_cb(void *buf, size_t len, void *payload) +{ + git_indexer_stream *idx = (git_indexer_stream *) payload; + + cl_git_pass(git_indexer_stream_add(idx, buf, len, &stats)); + + return 0; +} + +void test_pack_packbuilder__foreach(void) +{ + git_indexer_stream *idx; + + seed_packbuilder(); + cl_git_pass(git_indexer_stream_new(&idx, ".", NULL, NULL)); + cl_git_pass(git_packbuilder_foreach(_packbuilder, foreach_cb, idx)); + cl_git_pass(git_indexer_stream_finalize(idx, &stats)); + git_indexer_stream_free(idx); +} |