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:
authorMichael Schubert <schu@schu.io>2013-02-17 20:52:16 +0400
committerMichael Schubert <schu@schu.io>2013-02-26 01:22:15 +0400
commit6774b1071f946146978186460fd93bfb331bc786 (patch)
tree165e6db407ee2319465fb3e1a7c6452e0d8ca220 /tests-clar/pack
parentfcc265fef814c0428fb6300e7f89d4ee99311ee7 (diff)
tests/pack: do strict check of testpack's SHA1 hash
Diffstat (limited to 'tests-clar/pack')
-rw-r--r--tests-clar/pack/packbuilder.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c
index 513778781..84fc4d7bd 100644
--- a/tests-clar/pack/packbuilder.c
+++ b/tests-clar/pack/packbuilder.c
@@ -1,4 +1,6 @@
#include "clar_libgit2.h"
+#include "fileops.h"
+#include "hash.h"
#include "iterator.h"
#include "vector.h"
#include "posix.h"
@@ -76,6 +78,10 @@ static void seed_packbuilder(void)
void test_pack_packbuilder__create_pack(void)
{
git_transfer_progress stats;
+ git_buf buf = 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"));
@@ -83,6 +89,32 @@ void test_pack_packbuilder__create_pack(void)
cl_git_pass(git_indexer_new(&_indexer, "testpack.pack"));
cl_git_pass(git_indexer_run(_indexer, &stats));
cl_git_pass(git_indexer_write(_indexer));
+
+ /*
+ * By default, packfiles are created with only one thread.
+ * Therefore we can predict the object ordering and make sure
+ * we create exactly the same pack as git.git does when *not*
+ * reusing existing deltas (as libgit2).
+ *
+ * $ cd tests-clar/resources/testrepo.git
+ * $ git rev-list --objects HEAD | \
+ * git pack-objects -q --no-reuse-delta --threads=1 pack
+ * $ sha1sum git-80e61eb315239ef3c53033e37fee43b744d57122.pack
+ * 5d410bdf97cf896f9007681b92868471d636954b
+ *
+ */
+
+ cl_git_pass(git_futils_readbuffer(&buf, "testpack.pack"));
+
+ cl_git_pass(git_hash_init(&ctx));
+ cl_git_pass(git_hash_update(&ctx, buf.ptr, buf.size));
+ cl_git_pass(git_hash_final(&hash, &ctx));
+
+ git_buf_free(&buf);
+
+ git_oid_fmt(hex, &hash);
+
+ cl_assert_equal_s(hex, "5d410bdf97cf896f9007681b92868471d636954b");
}
static git_transfer_progress stats;