summaryrefslogtreecommitdiff
path: root/tests/libgit2/pack
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-09-21 05:09:46 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2023-02-12 22:02:00 +0000
commitfe2ee3a018286b04cd0c64f84d437c7317c8f138 (patch)
tree196a29fc72ef0a27e0277b4d142cc93c28fa4cb7 /tests/libgit2/pack
parent6204499242101d0f93cd7e56e259c900828e41e1 (diff)
downloadlibgit2-fe2ee3a018286b04cd0c64f84d437c7317c8f138.tar.gz
object: lookup sha256 objects
This is much of the plumbing for the object database to support SHA256, and for objects to be able to parse SHA256 versions of themselves.
Diffstat (limited to 'tests/libgit2/pack')
-rw-r--r--tests/libgit2/pack/indexer.c53
-rw-r--r--tests/libgit2/pack/packbuilder.c17
2 files changed, 68 insertions, 2 deletions
diff --git a/tests/libgit2/pack/indexer.c b/tests/libgit2/pack/indexer.c
index 2ac287255..9722decaf 100644
--- a/tests/libgit2/pack/indexer.c
+++ b/tests/libgit2/pack/indexer.c
@@ -100,7 +100,12 @@ void test_pack_indexer__out_of_order(void)
git_indexer *idx = 0;
git_indexer_progress stats = { 0 };
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
cl_git_pass(git_indexer_append(
idx, out_of_order_pack, out_of_order_pack_len, &stats));
cl_git_pass(git_indexer_commit(idx, &stats));
@@ -117,7 +122,12 @@ void test_pack_indexer__missing_trailer(void)
git_indexer *idx = 0;
git_indexer_progress stats = { 0 };
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
cl_git_pass(git_indexer_append(
idx, missing_trailer_pack, missing_trailer_pack_len, &stats));
cl_git_fail(git_indexer_commit(idx, &stats));
@@ -133,7 +143,12 @@ void test_pack_indexer__leaky(void)
git_indexer *idx = 0;
git_indexer_progress stats = { 0 };
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
cl_git_pass(git_indexer_append(
idx, leaky_pack, leaky_pack_len, &stats));
cl_git_fail(git_indexer_commit(idx, &stats));
@@ -151,6 +166,7 @@ void test_pack_indexer__fix_thin(void)
git_repository *repo;
git_odb *odb;
git_oid id, should_id;
+ git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
cl_git_pass(git_repository_init(&repo, "thin.git", true));
cl_git_pass(git_repository_odb(&odb, repo));
@@ -160,7 +176,13 @@ void test_pack_indexer__fix_thin(void)
git_oid__fromstr(&should_id, "e68fe8129b546b101aee9510c5328e7f21ca1d18", GIT_OID_SHA1);
cl_assert_equal_oid(&should_id, &id);
- cl_git_pass(git_indexer_new(&idx, ".", 0, odb, NULL));
+#ifdef GIT_EXPERIMENTAL_SHA256
+ opts.odb = odb;
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, &opts));
+#else
+ cl_git_pass(git_indexer_new(&idx, ".", 0, odb, &opts));
+#endif
+
cl_git_pass(git_indexer_append(idx, thin_pack, thin_pack_len, &stats));
cl_git_pass(git_indexer_commit(idx, &stats));
@@ -192,7 +214,12 @@ void test_pack_indexer__fix_thin(void)
cl_git_pass(p_stat(name, &st));
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
read = p_read(fd, buffer, sizeof(buffer));
cl_assert(read != -1);
p_close(fd);
@@ -216,6 +243,7 @@ void test_pack_indexer__corrupt_length(void)
git_repository *repo;
git_odb *odb;
git_oid id, should_id;
+ git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
cl_git_pass(git_repository_init(&repo, "thin.git", true));
cl_git_pass(git_repository_odb(&odb, repo));
@@ -225,7 +253,13 @@ void test_pack_indexer__corrupt_length(void)
git_oid__fromstr(&should_id, "e68fe8129b546b101aee9510c5328e7f21ca1d18", GIT_OID_SHA1);
cl_assert_equal_oid(&should_id, &id);
- cl_git_pass(git_indexer_new(&idx, ".", 0, odb, NULL));
+#ifdef GIT_EXPERIMENTAL_SHA256
+ opts.odb = odb;
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, &opts));
+#else
+ cl_git_pass(git_indexer_new(&idx, ".", 0, odb, &opts));
+#endif
+
cl_git_pass(git_indexer_append(
idx, corrupt_thin_pack, corrupt_thin_pack_len, &stats));
cl_git_fail(git_indexer_commit(idx, &stats));
@@ -246,7 +280,12 @@ void test_pack_indexer__incomplete_pack_fails_with_strict(void)
opts.verify = 1;
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, &opts));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, &opts));
+#endif
+
cl_git_pass(git_indexer_append(
idx, incomplete_pack, incomplete_pack_len, &stats));
cl_git_fail(git_indexer_commit(idx, &stats));
@@ -266,7 +305,12 @@ void test_pack_indexer__out_of_order_with_connectivity_checks(void)
opts.verify = 1;
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, &opts));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, &opts));
+#endif
+
cl_git_pass(git_indexer_append(
idx, out_of_order_pack, out_of_order_pack_len, &stats));
cl_git_pass(git_indexer_commit(idx, &stats));
@@ -309,7 +353,12 @@ void test_pack_indexer__no_tmp_files(void)
git_str_dispose(&path);
cl_assert(git_str_len(&first_tmp_file) == 0);
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
git_indexer_free(idx);
cl_git_pass(git_str_sets(&path, clar_sandbox_path()));
diff --git a/tests/libgit2/pack/packbuilder.c b/tests/libgit2/pack/packbuilder.c
index 0889f46ed..ff3dc1f68 100644
--- a/tests/libgit2/pack/packbuilder.c
+++ b/tests/libgit2/pack/packbuilder.c
@@ -104,7 +104,12 @@ void test_pack_packbuilder__create_pack(void)
seed_packbuilder();
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&_indexer, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&_indexer, ".", 0, NULL, NULL));
+#endif
+
cl_git_pass(git_packbuilder_foreach(_packbuilder, feed_indexer, &stats));
cl_git_pass(git_indexer_commit(_indexer, &stats));
@@ -244,7 +249,13 @@ void test_pack_packbuilder__foreach(void)
git_indexer *idx;
seed_packbuilder();
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
cl_git_pass(git_packbuilder_foreach(_packbuilder, foreach_cb, idx));
cl_git_pass(git_indexer_commit(idx, &_stats));
git_indexer_free(idx);
@@ -262,7 +273,13 @@ void test_pack_packbuilder__foreach_with_cancel(void)
git_indexer *idx;
seed_packbuilder();
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+ cl_git_pass(git_indexer_new(&idx, ".", GIT_OID_SHA1, NULL));
+#else
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
+#endif
+
cl_git_fail_with(
git_packbuilder_foreach(_packbuilder, foreach_cancel_cb, idx), -1111);
git_indexer_free(idx);