Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-03-03 18:19:21 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-03-03 18:19:21 +0400
commit447ae791e564ed887fb4abe752f38a1a9ada1267 (patch)
tree4d5f58504bcb7114e84bedeff0fde3e50a98894f /tests-clar/pack
parent01be786319238fd6507a08316d1c265c1a89407f (diff)
indexer: kill git_indexer
This was the first implementation and its goal was simply to have something that worked. It is slow and now it's just taking up space. Remove it and switch the one known usage to use the streaming indexer.
Diffstat (limited to 'tests-clar/pack')
-rw-r--r--tests-clar/pack/packbuilder.c26
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);