summaryrefslogtreecommitdiff
path: root/tests/libgit2/odb
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libgit2/odb')
-rw-r--r--tests/libgit2/odb/alternates.c4
-rw-r--r--tests/libgit2/odb/backend/backend_helpers.c12
-rw-r--r--tests/libgit2/odb/backend/mempack.c7
-rw-r--r--tests/libgit2/odb/backend/multiple.c2
-rw-r--r--tests/libgit2/odb/backend/nobackend.c3
-rw-r--r--tests/libgit2/odb/backend/nonrefreshing.c4
-rw-r--r--tests/libgit2/odb/backend/refreshing.c4
-rw-r--r--tests/libgit2/odb/backend/simple.c28
-rw-r--r--tests/libgit2/odb/emptyobjects.c6
-rw-r--r--tests/libgit2/odb/foreach.c2
-rw-r--r--tests/libgit2/odb/freshen.c12
-rw-r--r--tests/libgit2/odb/largefiles.c4
-rw-r--r--tests/libgit2/odb/loose.c144
-rw-r--r--tests/libgit2/odb/loose_data.h387
-rw-r--r--tests/libgit2/odb/mixed.c38
-rw-r--r--tests/libgit2/odb/packed.c8
-rw-r--r--tests/libgit2/odb/packed_one.c6
-rw-r--r--tests/libgit2/odb/sorting.c7
18 files changed, 573 insertions, 105 deletions
diff --git a/tests/libgit2/odb/alternates.c b/tests/libgit2/odb/alternates.c
index 6c00fda2f..4d2da6b1f 100644
--- a/tests/libgit2/odb/alternates.c
+++ b/tests/libgit2/odb/alternates.c
@@ -52,7 +52,7 @@ void test_odb_alternates__chained(void)
/* Now load B and see if we can find an object from testrepo.git */
cl_git_pass(git_repository_open(&repo, paths[1]));
- git_oid_fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+ git_oid__fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OID_SHA1);
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
git_commit_free(commit);
git_repository_free(repo);
@@ -74,7 +74,7 @@ void test_odb_alternates__long_chain(void)
/* Now load the last one and see if we can find an object from testrepo.git */
cl_git_pass(git_repository_open(&repo, paths[ARRAY_SIZE(paths)-1]));
- git_oid_fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750");
+ git_oid__fromstr(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OID_SHA1);
cl_git_fail(git_commit_lookup(&commit, repo, &oid));
git_repository_free(repo);
}
diff --git a/tests/libgit2/odb/backend/backend_helpers.c b/tests/libgit2/odb/backend/backend_helpers.c
index 542799242..c1a0070d6 100644
--- a/tests/libgit2/odb/backend/backend_helpers.c
+++ b/tests/libgit2/odb/backend/backend_helpers.c
@@ -9,7 +9,7 @@ static int search_object(const fake_object **out, fake_backend *fake, const git_
while (obj && obj->oid) {
git_oid current_oid;
- git_oid_fromstr(&current_oid, obj->oid);
+ git_oid__fromstr(&current_oid, obj->oid, GIT_OID_SHA1);
if (git_oid_ncmp(&current_oid, oid, len) == 0) {
if (found)
@@ -34,7 +34,7 @@ static int fake_backend__exists(git_odb_backend *backend, const git_oid *oid)
fake->exists_calls++;
- return search_object(NULL, fake, oid, GIT_OID_HEXSZ) == GIT_OK;
+ return search_object(NULL, fake, oid, GIT_OID_SHA1_HEXSIZE) == GIT_OK;
}
static int fake_backend__exists_prefix(
@@ -52,7 +52,7 @@ static int fake_backend__exists_prefix(
return error;
if (out)
- git_oid_fromstr(out, obj->oid);
+ git_oid__fromstr(out, obj->oid, GIT_OID_SHA1);
return 0;
}
@@ -69,7 +69,7 @@ static int fake_backend__read(
fake->read_calls++;
- if ((error = search_object(&obj, fake, oid, GIT_OID_HEXSZ)) < 0)
+ if ((error = search_object(&obj, fake, oid, GIT_OID_SHA1_HEXSIZE)) < 0)
return error;
*len_p = strlen(obj->content);
@@ -91,7 +91,7 @@ static int fake_backend__read_header(
fake->read_header_calls++;
- if ((error = search_object(&obj, fake, oid, GIT_OID_HEXSZ)) < 0)
+ if ((error = search_object(&obj, fake, oid, GIT_OID_SHA1_HEXSIZE)) < 0)
return error;
*len_p = strlen(obj->content);
@@ -115,7 +115,7 @@ static int fake_backend__read_prefix(
if ((error = search_object(&obj, fake, short_oid, len)) < 0)
return error;
- git_oid_fromstr(out_oid, obj->oid);
+ git_oid__fromstr(out_oid, obj->oid, GIT_OID_SHA1);
*len_p = strlen(obj->content);
*buffer_p = git__strdup(obj->content);
*type_p = GIT_OBJECT_BLOB;
diff --git a/tests/libgit2/odb/backend/mempack.c b/tests/libgit2/odb/backend/mempack.c
index 2eeed51aa..eb8ab3cb0 100644
--- a/tests/libgit2/odb/backend/mempack.c
+++ b/tests/libgit2/odb/backend/mempack.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "repository.h"
+#include "odb.h"
#include "backend_helpers.h"
#include "git2/sys/mempack.h"
@@ -13,7 +14,7 @@ void test_odb_backend_mempack__initialize(void)
git_odb_backend *backend;
cl_git_pass(git_mempack_new(&backend));
- cl_git_pass(git_odb_new(&_odb));
+ cl_git_pass(git_odb__new(&_odb, NULL));
cl_git_pass(git_odb_add_backend(_odb, backend, 10));
cl_git_pass(git_repository_wrap_odb(&_repo, _odb));
}
@@ -34,13 +35,13 @@ void test_odb_backend_mempack__write_succeeds(void)
void test_odb_backend_mempack__read_of_missing_object_fails(void)
{
- cl_git_pass(git_oid_fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633"));
+ cl_git_pass(git_oid__fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633", GIT_OID_SHA1));
cl_git_fail_with(GIT_ENOTFOUND, git_odb_read(&_obj, _odb, &_oid));
}
void test_odb_backend_mempack__exists_of_missing_object_fails(void)
{
- cl_git_pass(git_oid_fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633"));
+ cl_git_pass(git_oid__fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633", GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &_oid) == 0);
}
diff --git a/tests/libgit2/odb/backend/multiple.c b/tests/libgit2/odb/backend/multiple.c
index 5f1eacd52..97588164d 100644
--- a/tests/libgit2/odb/backend/multiple.c
+++ b/tests/libgit2/odb/backend/multiple.c
@@ -24,7 +24,7 @@ void test_odb_backend_multiple__initialize(void)
{
git_odb_backend *backend;
- git_oid_fromstr(&_existing_oid, EXISTING_HASH);
+ git_oid__fromstr(&_existing_oid, EXISTING_HASH, GIT_OID_SHA1);
_obj = NULL;
_repo = cl_git_sandbox_init("testrepo.git");
diff --git a/tests/libgit2/odb/backend/nobackend.c b/tests/libgit2/odb/backend/nobackend.c
index 7484d423b..7d9394c6f 100644
--- a/tests/libgit2/odb/backend/nobackend.c
+++ b/tests/libgit2/odb/backend/nobackend.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "repository.h"
+#include "odb.h"
#include "git2/sys/repository.h"
static git_repository *_repo;
@@ -12,7 +13,7 @@ void test_odb_backend_nobackend__initialize(void)
cl_git_pass(git_repository_new(&_repo));
cl_git_pass(git_config_new(&config));
- cl_git_pass(git_odb_new(&odb));
+ cl_git_pass(git_odb__new(&odb, NULL));
cl_git_pass(git_refdb_new(&refdb, _repo));
git_repository_set_config(_repo, config);
diff --git a/tests/libgit2/odb/backend/nonrefreshing.c b/tests/libgit2/odb/backend/nonrefreshing.c
index 2db10efbc..5084eb7f7 100644
--- a/tests/libgit2/odb/backend/nonrefreshing.c
+++ b/tests/libgit2/odb/backend/nonrefreshing.c
@@ -33,8 +33,8 @@ static void setup_repository_and_backend(void)
void test_odb_backend_nonrefreshing__initialize(void)
{
- git_oid_fromstr(&_nonexisting_oid, NONEXISTING_HASH);
- git_oid_fromstr(&_existing_oid, EXISTING_HASH);
+ git_oid__fromstr(&_nonexisting_oid, NONEXISTING_HASH, GIT_OID_SHA1);
+ git_oid__fromstr(&_existing_oid, EXISTING_HASH, GIT_OID_SHA1);
setup_repository_and_backend();
}
diff --git a/tests/libgit2/odb/backend/refreshing.c b/tests/libgit2/odb/backend/refreshing.c
index 9e49298a8..fcba748ee 100644
--- a/tests/libgit2/odb/backend/refreshing.c
+++ b/tests/libgit2/odb/backend/refreshing.c
@@ -33,8 +33,8 @@ static void setup_repository_and_backend(void)
void test_odb_backend_refreshing__initialize(void)
{
- git_oid_fromstr(&_nonexisting_oid, NONEXISTING_HASH);
- git_oid_fromstr(&_existing_oid, EXISTING_HASH);
+ git_oid__fromstr(&_nonexisting_oid, NONEXISTING_HASH, GIT_OID_SHA1);
+ git_oid__fromstr(&_existing_oid, EXISTING_HASH, GIT_OID_SHA1);
setup_repository_and_backend();
}
diff --git a/tests/libgit2/odb/backend/simple.c b/tests/libgit2/odb/backend/simple.c
index 6c9293ac0..25dfd90a2 100644
--- a/tests/libgit2/odb/backend/simple.c
+++ b/tests/libgit2/odb/backend/simple.c
@@ -49,7 +49,7 @@ void test_odb_backend_simple__read_of_object_succeeds(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_pass(git_odb_read(&_obj, _odb, &_oid));
assert_object_contains(_obj, objs[0].content);
@@ -64,7 +64,7 @@ void test_odb_backend_simple__read_of_nonexisting_object_fails(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633"));
+ cl_git_pass(git_oid__fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633", GIT_OID_SHA1));
cl_git_fail_with(GIT_ENOTFOUND, git_odb_read(&_obj, _odb, &_oid));
}
@@ -77,7 +77,7 @@ void test_odb_backend_simple__read_with_hash_mismatch_fails(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_fail_with(GIT_EMISMATCH, git_odb_read(&_obj, _odb, &_oid));
}
@@ -89,7 +89,7 @@ void test_odb_backend_simple__read_with_hash_mismatch_succeeds_without_verificat
};
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 0));
cl_git_pass(git_odb_read(&_obj, _odb, &_oid));
@@ -106,7 +106,7 @@ void test_odb_backend_simple__read_prefix_succeeds(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4632"));
+ cl_git_pass(git_oid__fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4632", GIT_OID_SHA1));
cl_git_pass(git_odb_read(&_obj, _odb, &_oid));
assert_object_contains(_obj, objs[0].content);
@@ -122,7 +122,7 @@ void test_odb_backend_simple__read_prefix_of_nonexisting_object_fails(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstrn(&_oid, hash, strlen(hash)));
+ cl_git_pass(git_oid__fromstrn(&_oid, hash, strlen(hash), GIT_OID_SHA1));
cl_git_fail_with(GIT_ENOTFOUND, git_odb_read(&_obj, _odb, &_oid));
}
@@ -136,7 +136,7 @@ void test_odb_backend_simple__read_with_ambiguous_prefix_fails(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_fail_with(GIT_EAMBIGUOUS, git_odb_read_prefix(&_obj, _odb, &_oid, 7));
}
@@ -150,7 +150,7 @@ void test_odb_backend_simple__read_with_highly_ambiguous_prefix(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 0));
cl_git_fail_with(GIT_EAMBIGUOUS, git_odb_read_prefix(&_obj, _odb, &_oid, 39));
cl_git_pass(git_odb_read_prefix(&_obj, _odb, &_oid, 40));
@@ -166,7 +166,7 @@ void test_odb_backend_simple__exists_succeeds(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &_oid));
}
@@ -179,7 +179,7 @@ void test_odb_backend_simple__exists_fails_for_nonexisting_object(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633"));
+ cl_git_pass(git_oid__fromstr(&_oid, "f6ea0495187600e7b2288c8ac19c5886383a4633", GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &_oid) == 0);
}
@@ -194,7 +194,7 @@ void test_odb_backend_simple__exists_prefix_succeeds(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_pass(git_odb_exists_prefix(&found, _odb, &_oid, 12));
cl_assert(git_oid_equal(&found, &_oid));
}
@@ -209,7 +209,7 @@ void test_odb_backend_simple__exists_with_ambiguous_prefix_fails(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_fail_with(GIT_EAMBIGUOUS, git_odb_exists_prefix(NULL, _odb, &_oid, 7));
}
@@ -224,7 +224,7 @@ void test_odb_backend_simple__exists_with_highly_ambiguous_prefix(void)
setup_backend(objs);
- cl_git_pass(git_oid_fromstr(&_oid, objs[0].oid));
+ cl_git_pass(git_oid__fromstr(&_oid, objs[0].oid, GIT_OID_SHA1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 0));
cl_git_fail_with(GIT_EAMBIGUOUS, git_odb_exists_prefix(&found, _odb, &_oid, 39));
cl_git_pass(git_odb_exists_prefix(&found, _odb, &_oid, 40));
@@ -237,7 +237,7 @@ void test_odb_backend_simple__null_oid_is_ignored(void)
{ "0000000000000000000000000000000000000000", "null oid content" },
{ NULL, NULL }
};
- git_oid null_oid = {{0}};
+ git_oid null_oid = GIT_OID_SHA1_ZERO;
git_odb_object *obj;
setup_backend(objs);
diff --git a/tests/libgit2/odb/emptyobjects.c b/tests/libgit2/odb/emptyobjects.c
index e3ec62d3f..e7cc668d1 100644
--- a/tests/libgit2/odb/emptyobjects.c
+++ b/tests/libgit2/odb/emptyobjects.c
@@ -24,7 +24,7 @@ void test_odb_emptyobjects__blob_notfound(void)
git_oid id, written_id;
git_blob *blob;
- cl_git_pass(git_oid_fromstr(&id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
+ cl_git_pass(git_oid__fromstr(&id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", GIT_OID_SHA1));
cl_git_fail_with(GIT_ENOTFOUND, git_blob_lookup(&blob, g_repo, &id));
cl_git_pass(git_odb_write(&written_id, g_odb, "", 0, GIT_OBJECT_BLOB));
@@ -36,7 +36,7 @@ void test_odb_emptyobjects__read_tree(void)
git_oid id;
git_tree *tree;
- cl_git_pass(git_oid_fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904"));
+ cl_git_pass(git_oid__fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", GIT_OID_SHA1));
cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
cl_assert_equal_i(GIT_OBJECT_TREE, git_object_type((git_object *) tree));
cl_assert_equal_i(0, git_tree_entrycount(tree));
@@ -49,7 +49,7 @@ void test_odb_emptyobjects__read_tree_odb(void)
git_oid id;
git_odb_object *tree_odb;
- cl_git_pass(git_oid_fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904"));
+ cl_git_pass(git_oid__fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", GIT_OID_SHA1));
cl_git_pass(git_odb_read(&tree_odb, g_odb, &id));
cl_assert(git_odb_object_data(tree_odb));
cl_assert_equal_s("", git_odb_object_data(tree_odb));
diff --git a/tests/libgit2/odb/foreach.c b/tests/libgit2/odb/foreach.c
index c2a448363..165a511a0 100644
--- a/tests/libgit2/odb/foreach.c
+++ b/tests/libgit2/odb/foreach.c
@@ -51,7 +51,7 @@ void test_odb_foreach__one_pack(void)
git_odb_backend *backend = NULL;
int nobj = 0;
- cl_git_pass(git_odb_new(&_odb));
+ cl_git_pass(git_odb__new(&_odb, NULL));
cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")));
cl_git_pass(git_odb_add_backend(_odb, backend, 1));
_repo = NULL;
diff --git a/tests/libgit2/odb/freshen.c b/tests/libgit2/odb/freshen.c
index 2396e3774..e337c82b7 100644
--- a/tests/libgit2/odb/freshen.c
+++ b/tests/libgit2/odb/freshen.c
@@ -43,7 +43,7 @@ void test_odb_freshen__loose_blob(void)
git_oid expected_id, id;
struct stat before, after;
- cl_git_pass(git_oid_fromstr(&expected_id, LOOSE_BLOB_ID));
+ cl_git_pass(git_oid__fromstr(&expected_id, LOOSE_BLOB_ID, GIT_OID_SHA1));
set_time_wayback(&before, LOOSE_BLOB_FN);
/* make sure we freshen a blob */
@@ -64,7 +64,7 @@ void test_odb_freshen__readonly_object(void)
git_oid expected_id, id;
struct stat before, after;
- cl_git_pass(git_oid_fromstr(&expected_id, UNIQUE_BLOB_ID));
+ cl_git_pass(git_oid__fromstr(&expected_id, UNIQUE_BLOB_ID, GIT_OID_SHA1));
cl_git_pass(git_blob_create_from_buffer(&id, repo, UNIQUE_STR, CONST_STRLEN(UNIQUE_STR)));
cl_assert_equal_oid(&expected_id, &id);
@@ -89,7 +89,7 @@ void test_odb_freshen__loose_tree(void)
git_tree *tree;
struct stat before, after;
- cl_git_pass(git_oid_fromstr(&expected_id, LOOSE_TREE_ID));
+ cl_git_pass(git_oid__fromstr(&expected_id, LOOSE_TREE_ID, GIT_OID_SHA1));
set_time_wayback(&before, LOOSE_TREE_FN);
cl_git_pass(git_tree_lookup(&tree, repo, &expected_id));
@@ -113,11 +113,11 @@ void test_odb_freshen__tree_during_commit(void)
git_signature *signature;
struct stat before, after;
- cl_git_pass(git_oid_fromstr(&tree_id, LOOSE_TREE_ID));
+ cl_git_pass(git_oid__fromstr(&tree_id, LOOSE_TREE_ID, GIT_OID_SHA1));
cl_git_pass(git_tree_lookup(&tree, repo, &tree_id));
set_time_wayback(&before, LOOSE_TREE_FN);
- cl_git_pass(git_oid_fromstr(&parent_id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
+ cl_git_pass(git_oid__fromstr(&parent_id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OID_SHA1));
cl_git_pass(git_commit_lookup(&parent, repo, &parent_id));
cl_git_pass(git_signature_new(&signature,
@@ -147,7 +147,7 @@ void test_odb_freshen__packed_object(void)
struct stat before, after;
struct p_timeval old_times[2];
- cl_git_pass(git_oid_fromstr(&expected_id, PACKED_ID));
+ cl_git_pass(git_oid__fromstr(&expected_id, PACKED_ID, GIT_OID_SHA1));
old_times[0].tv_sec = 1234567890;
old_times[0].tv_usec = 0;
diff --git a/tests/libgit2/odb/largefiles.c b/tests/libgit2/odb/largefiles.c
index acc786ee4..2ec48102b 100644
--- a/tests/libgit2/odb/largefiles.c
+++ b/tests/libgit2/odb/largefiles.c
@@ -57,7 +57,7 @@ void test_odb_largefiles__write_from_memory(void)
for (i = 0; i < (3041*126103); i++)
cl_git_pass(git_str_puts(&buf, "Hello, world.\n"));
- git_oid_fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c");
+ git_oid__fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c", GIT_OID_SHA1);
cl_git_pass(git_odb_write(&oid, odb, buf.ptr, buf.size, GIT_OBJECT_BLOB));
cl_assert_equal_oid(&expected, &oid);
@@ -75,7 +75,7 @@ void test_odb_largefiles__streamwrite(void)
!cl_is_env_set("GITTEST_SLOW"))
cl_skip();
- git_oid_fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c");
+ git_oid__fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c", GIT_OID_SHA1);
writefile(&oid);
cl_assert_equal_oid(&expected, &oid);
diff --git a/tests/libgit2/odb/loose.c b/tests/libgit2/odb/loose.c
index fe013a78c..e79525478 100644
--- a/tests/libgit2/odb/loose.c
+++ b/tests/libgit2/odb/loose.c
@@ -34,24 +34,27 @@ static void cmp_objects(git_rawobj *o, object_data *d)
static void test_read_object(object_data *data)
{
- git_oid id;
- git_odb_object *obj;
+ git_oid id;
+ git_odb_object *obj;
git_odb *odb;
git_rawobj tmp;
+ git_odb_options opts = GIT_ODB_OPTIONS_INIT;
+
+ opts.oid_type = data->id_type;
- write_object_files(data);
+ write_object_files(data);
- cl_git_pass(git_odb_open(&odb, "test-objects"));
- cl_git_pass(git_oid_fromstr(&id, data->id));
- cl_git_pass(git_odb_read(&obj, odb, &id));
+ cl_git_pass(git_odb__open(&odb, "test-objects", &opts));
+ cl_git_pass(git_oid__fromstr(&id, data->id, data->id_type));
+ cl_git_pass(git_odb_read(&obj, odb, &id));
tmp.data = obj->buffer;
tmp.len = obj->cached.size;
tmp.type = obj->cached.type;
- cmp_objects(&tmp, data);
+ cmp_objects(&tmp, data);
- git_odb_object_free(obj);
+ git_odb_object_free(obj);
git_odb_free(odb);
}
@@ -61,11 +64,14 @@ static void test_read_header(object_data *data)
git_odb *odb;
size_t len;
git_object_t type;
+ git_odb_options opts = GIT_ODB_OPTIONS_INIT;
+
+ opts.oid_type = data->id_type;
write_object_files(data);
- cl_git_pass(git_odb_open(&odb, "test-objects"));
- cl_git_pass(git_oid_fromstr(&id, data->id));
+ cl_git_pass(git_odb__open(&odb, "test-objects", &opts));
+ cl_git_pass(git_oid__fromstr(&id, data->id, data->id_type));
cl_git_pass(git_odb_read_header(&len, &type, odb, &id));
cl_assert_equal_sz(data->dlen, len);
@@ -83,11 +89,14 @@ static void test_readstream_object(object_data *data, size_t blocksize)
char buf[2048], *ptr = buf;
size_t remain;
int ret;
+ git_odb_options opts = GIT_ODB_OPTIONS_INIT;
+
+ opts.oid_type = data->id_type;
write_object_files(data);
- cl_git_pass(git_odb_open(&odb, "test-objects"));
- cl_git_pass(git_oid_fromstr(&id, data->id));
+ cl_git_pass(git_odb__open(&odb, "test-objects", &opts));
+ cl_git_pass(git_oid__fromstr(&id, data->id, data->id_type));
cl_git_pass(git_odb_open_rstream(&stream, &tmp.len, &tmp.type, odb, &id));
remain = tmp.len;
@@ -124,32 +133,62 @@ void test_odb_loose__cleanup(void)
cl_fixture_cleanup("test-objects");
}
-void test_odb_loose__exists(void)
+void test_odb_loose__exists_sha1(void)
{
git_oid id, id2;
git_odb *odb;
write_object_files(&one);
- cl_git_pass(git_odb_open(&odb, "test-objects"));
+ cl_git_pass(git_odb__open(&odb, "test-objects", NULL));
- cl_git_pass(git_oid_fromstr(&id, one.id));
+ cl_git_pass(git_oid__fromstr(&id, one.id, GIT_OID_SHA1));
cl_assert(git_odb_exists(odb, &id));
- cl_git_pass(git_oid_fromstrp(&id, "8b137891"));
+ cl_git_pass(git_oid__fromstrp(&id, "8b137891", GIT_OID_SHA1));
cl_git_pass(git_odb_exists_prefix(&id2, odb, &id, 8));
cl_assert_equal_i(0, git_oid_streq(&id2, one.id));
/* Test for a missing object */
- cl_git_pass(git_oid_fromstr(&id, "8b137891791fe96927ad78e64b0aad7bded08baa"));
+ cl_git_pass(git_oid__fromstr(&id, "8b137891791fe96927ad78e64b0aad7bded08baa", GIT_OID_SHA1));
cl_assert(!git_odb_exists(odb, &id));
- cl_git_pass(git_oid_fromstrp(&id, "8b13789a"));
+ cl_git_pass(git_oid__fromstrp(&id, "8b13789a", GIT_OID_SHA1));
cl_assert_equal_i(GIT_ENOTFOUND, git_odb_exists_prefix(&id2, odb, &id, 8));
git_odb_free(odb);
}
-void test_odb_loose__simple_reads(void)
+void test_odb_loose__exists_sha256(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ git_oid id, id2;
+ git_odb *odb;
+ git_odb_options odb_opts = GIT_ODB_OPTIONS_INIT;
+
+ odb_opts.oid_type = GIT_OID_SHA256;
+
+ write_object_files(&one_sha256);
+ cl_git_pass(git_odb__open(&odb, "test-objects", &odb_opts));
+
+ cl_git_pass(git_oid__fromstr(&id, one_sha256.id, GIT_OID_SHA256));
+ cl_assert(git_odb_exists(odb, &id));
+
+ cl_git_pass(git_oid__fromstrp(&id, "4c0d52d1", GIT_OID_SHA256));
+ cl_git_pass(git_odb_exists_prefix(&id2, odb, &id, 8));
+ cl_assert_equal_i(0, git_oid_streq(&id2, one_sha256.id));
+
+ /* Test for a missing object */
+ cl_git_pass(git_oid__fromstr(&id, "4c0d52d180c61d01ce1a91dec5ee58f0cbe65fd59433aea803ab927965493faa", GIT_OID_SHA256));
+ cl_assert(!git_odb_exists(odb, &id));
+
+ cl_git_pass(git_oid__fromstrp(&id, "4c0d52da", GIT_OID_SHA256));
+ cl_assert_equal_i(GIT_ENOTFOUND, git_odb_exists_prefix(&id2, odb, &id, 8));
+
+ git_odb_free(odb);
+#endif
+}
+
+void test_odb_loose__simple_reads_sha1(void)
{
test_read_object(&commit);
test_read_object(&tree);
@@ -160,7 +199,20 @@ void test_odb_loose__simple_reads(void)
test_read_object(&some);
}
-void test_odb_loose__streaming_reads(void)
+void test_odb_loose__simple_reads_sha256(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ test_read_object(&commit_sha256);
+ test_read_object(&tree_sha256);
+ test_read_object(&tag_sha256);
+ test_read_object(&zero_sha256);
+ test_read_object(&one_sha256);
+ test_read_object(&two_sha256);
+ test_read_object(&some_sha256);
+#endif
+}
+
+void test_odb_loose__streaming_reads_sha1(void)
{
size_t blocksizes[] = { 1, 2, 4, 16, 99, 1024, 123456789 };
size_t i;
@@ -176,7 +228,25 @@ void test_odb_loose__streaming_reads(void)
}
}
-void test_odb_loose__read_header(void)
+void test_odb_loose__streaming_reads_sha256(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ size_t blocksizes[] = { 1, 2, 4, 16, 99, 1024, 123456789 };
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(blocksizes); i++) {
+ test_readstream_object(&commit_sha256, blocksizes[i]);
+ test_readstream_object(&tree_sha256, blocksizes[i]);
+ test_readstream_object(&tag_sha256, blocksizes[i]);
+ test_readstream_object(&zero_sha256, blocksizes[i]);
+ test_readstream_object(&one_sha256, blocksizes[i]);
+ test_readstream_object(&two_sha256, blocksizes[i]);
+ test_readstream_object(&some_sha256, blocksizes[i]);
+ }
+#endif
+}
+
+void test_odb_loose__read_header_sha1(void)
{
test_read_header(&commit);
test_read_header(&tree);
@@ -187,6 +257,19 @@ void test_odb_loose__read_header(void)
test_read_header(&some);
}
+void test_odb_loose__read_header_sha256(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ test_read_header(&commit_sha256);
+ test_read_header(&tree_sha256);
+ test_read_header(&tag_sha256);
+ test_read_header(&zero_sha256);
+ test_read_header(&one_sha256);
+ test_read_header(&two_sha256);
+ test_read_header(&some_sha256);
+#endif
+}
+
static void test_write_object_permission(
mode_t dir_mode, mode_t file_mode,
mode_t expected_dir_mode, mode_t expected_file_mode)
@@ -196,6 +279,7 @@ static void test_write_object_permission(
git_oid oid;
struct stat statbuf;
mode_t mask, os_mask;
+ git_odb_backend_loose_options opts = GIT_ODB_BACKEND_LOOSE_OPTIONS_INIT;
/* Windows does not return group/user bits from stat,
* files are never executable.
@@ -209,8 +293,11 @@ static void test_write_object_permission(
mask = p_umask(0);
p_umask(mask);
- cl_git_pass(git_odb_new(&odb));
- cl_git_pass(git_odb_backend_loose(&backend, "test-objects", -1, 0, dir_mode, file_mode));
+ opts.dir_mode = dir_mode;
+ opts.file_mode = file_mode;
+
+ cl_git_pass(git_odb__new(&odb, NULL));
+ cl_git_pass(git_odb__backend_loose(&backend, "test-objects", &opts));
cl_git_pass(git_odb_add_backend(odb, backend, 1));
cl_git_pass(git_odb_write(&oid, odb, "Test data\n", 10, GIT_OBJECT_BLOB));
@@ -243,9 +330,16 @@ static void write_object_to_loose_odb(int fsync)
git_odb *odb;
git_odb_backend *backend;
git_oid oid;
+ git_odb_backend_loose_options opts = GIT_ODB_BACKEND_LOOSE_OPTIONS_INIT;
+
+ if (fsync)
+ opts.flags |= GIT_ODB_BACKEND_LOOSE_FSYNC;
+
+ opts.dir_mode = 0777;
+ opts.file_mode = 0666;
- cl_git_pass(git_odb_new(&odb));
- cl_git_pass(git_odb_backend_loose(&backend, "test-objects", -1, fsync, 0777, 0666));
+ cl_git_pass(git_odb__new(&odb, NULL));
+ cl_git_pass(git_odb__backend_loose(&backend, "test-objects", &opts));
cl_git_pass(git_odb_add_backend(odb, backend, 1));
cl_git_pass(git_odb_write(&oid, odb, "Test data\n", 10, GIT_OBJECT_BLOB));
git_odb_free(odb);
diff --git a/tests/libgit2/odb/loose_data.h b/tests/libgit2/odb/loose_data.h
index c10c9bc7f..1a830740d 100644
--- a/tests/libgit2/odb/loose_data.h
+++ b/tests/libgit2/odb/loose_data.h
@@ -1,7 +1,8 @@
typedef struct object_data {
unsigned char *bytes; /* (compressed) bytes stored in object store */
size_t blen; /* length of data in object store */
- char *id; /* object id (sha1) */
+ char *id; /* object id (hex chars) */
+ git_oid_t id_type; /* type of object id (sha1 or sha256) */
char *type; /* object type */
char *dir; /* object store (fan-out) directory name */
char *file; /* object store filename */
@@ -9,7 +10,10 @@ typedef struct object_data {
size_t dlen; /* length of (uncompressed) object data */
} object_data;
-/* one == 8b137891791fe96927ad78e64b0aad7bded08bdc */
+/*
+ * one == 8b137891791fe96927ad78e64b0aad7bded08bdc (sha1)
+ * 4c0d52d180c61d01ce1a91dec5ee58f0cbe65fd59433aea803ab927965493fd7 (sha256)
+ */
static unsigned char one_bytes[] = {
0x31, 0x78, 0x9c, 0xe3, 0x02, 0x00, 0x00, 0x0b,
0x00, 0x0b,
@@ -23,6 +27,7 @@ static object_data one = {
one_bytes,
sizeof(one_bytes),
"8b137891791fe96927ad78e64b0aad7bded08bdc",
+ GIT_OID_SHA1,
"blob",
"test-objects/8b",
"test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc",
@@ -30,8 +35,25 @@ static object_data one = {
sizeof(one_data),
};
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data one_sha256 = {
+ one_bytes,
+ sizeof(one_bytes),
+ "4c0d52d180c61d01ce1a91dec5ee58f0cbe65fd59433aea803ab927965493fd7",
+ GIT_OID_SHA256,
+ "blob",
+ "test-objects/4c",
+ "test-objects/4c/0d52d180c61d01ce1a91dec5ee58f0cbe65fd59433aea803ab927965493fd7",
+ one_data,
+ sizeof(one_data),
+};
+#endif
-/* commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 */
+
+/*
+ * commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 (sha1)
+ * a2a430fb63b294f868af4ef6ccc9c3e8256e370859ce578a23837ac85337f562 (sha256)
+ */
static unsigned char commit_bytes[] = {
0x78, 0x01, 0x85, 0x50, 0xc1, 0x6a, 0xc3, 0x30,
0x0c, 0xdd, 0xd9, 0x5f, 0xa1, 0xfb, 0x96, 0x12,
@@ -64,6 +86,42 @@ static unsigned char commit_bytes[] = {
0x1f, 0x78, 0x35,
};
+#ifdef GIT_EXPERIMENTAL_SHA256
+static unsigned char commit_bytes_sha256[] = {
+ 0x78, 0x01, 0x85, 0x90, 0xc1, 0x4e, 0xc3, 0x30,
+ 0x0c, 0x86, 0x39, 0xe7, 0x29, 0x7c, 0x87, 0x4e,
+ 0x5d, 0x93, 0xa6, 0x2d, 0x9a, 0x10, 0x13, 0x67,
+ 0xc4, 0x81, 0xf1, 0x00, 0x4e, 0xe3, 0xb4, 0x91,
+ 0x9a, 0xa4, 0x4a, 0x53, 0x69, 0x7d, 0x7b, 0x82,
+ 0x3a, 0x4d, 0x9c, 0xc0, 0xa7, 0xcf, 0xbf, 0xfd,
+ 0xff, 0xb2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 0x2b, 0xfe, 0xc0, 0xd8, 0xa7, 0x1d, 0x3c, 0xe9,
+ 0x22, 0x98, 0x42, 0x6d, 0xcf, 0x7f, 0xbf, 0x83,
+ 0x7d, 0x03, 0x6d, 0x1e, 0x7e, 0xa9
+};
+#endif
+
static unsigned char commit_data[] = {
0x74, 0x72, 0x65, 0x65, 0x20, 0x64, 0x66, 0x66,
0x32, 0x64, 0x61, 0x39, 0x30, 0x62, 0x32, 0x35,
@@ -112,10 +170,64 @@ static unsigned char commit_data[] = {
0x3e, 0x0a,
};
+#ifdef GIT_EXPERIMENTAL_SHA256
+static unsigned char commit_data_sha256[] = {
+ 0x74, 0x72, 0x65, 0x65, 0x20, 0x33, 0x34, 0x61,
+ 0x34, 0x38, 0x35, 0x34, 0x62, 0x35, 0x34, 0x32,
+ 0x36, 0x66, 0x39, 0x32, 0x34, 0x36, 0x30, 0x62,
+ 0x34, 0x61, 0x65, 0x33, 0x35, 0x65, 0x36, 0x64,
+ 0x37, 0x39, 0x37, 0x34, 0x36, 0x62, 0x65, 0x36,
+ 0x36, 0x63, 0x33, 0x38, 0x62, 0x66, 0x66, 0x64,
+ 0x36, 0x65, 0x66, 0x33, 0x62, 0x63, 0x34, 0x66,
+ 0x30, 0x35, 0x33, 0x65, 0x64, 0x37, 0x38, 0x61,
+ 0x33, 0x36, 0x62, 0x61, 0x34, 0x0a, 0x61, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x20, 0x41, 0x20, 0x55,
+ 0x20, 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61,
+ 0x75, 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78,
+ 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
+ 0x6d, 0x3e, 0x20, 0x31, 0x32, 0x32, 0x37, 0x38,
+ 0x31, 0x34, 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30,
+ 0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
+ 0x69, 0x74, 0x74, 0x65, 0x72, 0x20, 0x43, 0x20,
+ 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
+ 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
+ 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
+ 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
+ 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
+ 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
+ 0x30, 0x0a, 0x0a, 0x41, 0x20, 0x6f, 0x6e, 0x65,
+ 0x2d, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x75, 0x6d,
+ 0x6d, 0x61, 0x72, 0x79, 0x0a, 0x0a, 0x54, 0x68,
+ 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x6f,
+ 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x6d, 0x65, 0x73,
+ 0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67,
+ 0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6f, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x72, 0x70,
+ 0x6f, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
+ 0x65, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x72, 0x6f,
+ 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d,
+ 0x6d, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x53, 0x69,
+ 0x67, 0x6e, 0x65, 0x64, 0x2d, 0x6f, 0x66, 0x2d,
+ 0x62, 0x79, 0x3a, 0x20, 0x41, 0x20, 0x55, 0x20,
+ 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78, 0x61,
+ 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x3e, 0x0a
+};
+#endif
+
static object_data commit = {
commit_bytes,
sizeof(commit_bytes),
"3d7f8a6af076c8c3f20071a8935cdbe8228594d1",
+ GIT_OID_SHA1,
"commit",
"test-objects/3d",
"test-objects/3d/7f8a6af076c8c3f20071a8935cdbe8228594d1",
@@ -123,7 +235,24 @@ static object_data commit = {
sizeof(commit_data),
};
-/* tree == dff2da90b254e1beb889d1f1f1288be1803782df */
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data commit_sha256 = {
+ commit_bytes_sha256,
+ sizeof(commit_bytes_sha256),
+ "a2a430fb63b294f868af4ef6ccc9c3e8256e370859ce578a23837ac85337f562",
+ GIT_OID_SHA256,
+ "commit",
+ "test-objects/a2",
+ "test-objects/a2/a430fb63b294f868af4ef6ccc9c3e8256e370859ce578a23837ac85337f562",
+ commit_data_sha256,
+ sizeof(commit_data_sha256),
+};
+#endif
+
+/*
+ * tree == dff2da90b254e1beb889d1f1f1288be1803782df (sha1)
+ * 34a4854b5426f92460b4ae35e6d79746be66c38bffd6ef3bc4f053ed78a36ba4 (sha256)
+ */
static unsigned char tree_bytes[] = {
0x78, 0x01, 0x2b, 0x29, 0x4a, 0x4d, 0x55, 0x30,
0x34, 0x32, 0x63,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65, 0x49, 0x3f, 0xd7, 0x31, 0x30, 0x30, 0x36,
+ 0x34, 0x34, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x00,
+ 0x08, 0x3c, 0x2b, 0x8b, 0x44, 0x56, 0x40, 0xd1,
+ 0x71, 0xe7, 0xaa, 0x66, 0x7b, 0x0b, 0x32, 0x00,
+ 0x70, 0x06, 0xf7, 0x86, 0x71, 0x10, 0x32, 0xeb,
+ 0xb8, 0x29, 0x31, 0xcc, 0xa6, 0x9c, 0xc1, 0x5b,
+ 0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x74,
+ 0x77, 0x6f, 0x00, 0xf8, 0x62, 0x5e, 0x43, 0xf9,
+ 0xe0, 0x4f, 0x24, 0x29, 0x1f, 0x77, 0xcd, 0xbe,
+ 0x4c, 0x71, 0xb3, 0xc2, 0xa3, 0xb0, 0x00, 0x3f,
+ 0x60, 0x41, 0x9b, 0x3e, 0xd0, 0x6a, 0x05, 0x8d,
+ 0x76, 0x6c, 0x8b, 0x31, 0x30, 0x30, 0x36, 0x34,
+ 0x34, 0x20, 0x7a, 0x65, 0x72, 0x6f, 0x00, 0x44,
+ 0x9e, 0x9b, 0x79, 0x54, 0x20, 0xcd, 0x16, 0xfe,
+ 0x60, 0xad, 0x52, 0x98, 0xcf, 0x68, 0x0f, 0x15,
+ 0xa7, 0xcd, 0x2a, 0xc9, 0xb4, 0x4a, 0xda, 0xf7,
+ 0xed, 0x3e, 0xdc, 0x0d, 0x08, 0xdd, 0x78
+};
+#endif
+
static object_data tree = {
tree_bytes,
sizeof(tree_bytes),
"dff2da90b254e1beb889d1f1f1288be1803782df",
+ GIT_OID_SHA1,
"tree",
"test-objects/df",
"test-objects/df/f2da90b254e1beb889d1f1f1288be1803782df",
@@ -174,7 +369,24 @@ static object_data tree = {
sizeof(tree_data),
};
-/* tag == 09d373e1dfdc16b129ceec6dd649739911541e05 */
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data tree_sha256 = {
+ tree_bytes_sha256,
+ sizeof(tree_bytes_sha256),
+ "34a4854b5426f92460b4ae35e6d79746be66c38bffd6ef3bc4f053ed78a36ba4",
+ GIT_OID_SHA256,
+ "tree",
+ "test-objects/34",
+ "test-objects/34/a4854b5426f92460b4ae35e6d79746be66c38bffd6ef3bc4f053ed78a36ba4",
+ tree_data_sha256,
+ sizeof(tree_data_sha256),
+};
+#endif
+
+/*
+ * tag == 09d373e1dfdc16b129ceec6dd649739911541e05 (sha1)
+ * f535d7595d5d0e5e530b5deb34542c96491fea300a1318036b605306548cb225 (sha256)
+ */
static unsigned char tag_bytes[] = {
0x78, 0x01, 0x35, 0x4e, 0xcb, 0x0a, 0xc2, 0x40,
0x10, 0xf3, 0xbc, 0x5f, 0x31, 0x77, 0xa1, 0xec,
@@ -222,10 +434,101 @@ static unsigned char tag_data[] = {
0x2e, 0x30, 0x2e, 0x31, 0x0a,
};
+#ifdef GIT_EXPERIMENTAL_SHA256
+static unsigned char tag_bytes_sha256[] = {
+ 0x78, 0x01, 0x55, 0x8f, 0xd1, 0x4e, 0x84, 0x30,
+ 0x10, 0x45, 0x7d, 0xee, 0x57, 0xcc, 0xbb, 0x2e,
+ 0x81, 0x16, 0x68, 0x31, 0x1b, 0xa3, 0xf1, 0xd9,
+ 0xf8, 0xe0, 0xfa, 0x01, 0x43, 0x99, 0x42, 0x0d,
+ 0xb4, 0xa4, 0x14, 0xb3, 0xfc, 0xbd, 0xc5, 0xdd,
+ 0x4d, 0xb4, 0x69, 0xd2, 0x9b, 0xc9, 0xdc, 0x7b,
+ 0x6e, 0x23, 0xf6, 0x20, 0xa4, 0xba, 0xf3, 0xed,
+ 0x17, 0xe9, 0x08, 0xc8, 0xb1, 0x14, 0xb9, 0x69,
+ 0x6b, 0xd1, 0xf2, 0xa6, 0x34, 0xaa, 0x56, 0x68,
+ 0x4a, 0x32, 0xb5, 0xd6, 0xba, 0xd1, 0x82, 0x14,
+ 0xaf, 0x6a, 0x12, 0x32, 0x57, 0x55,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4, 0xfe, 0xfb, 0x30, 0xfb,
+ 0x01, 0xc9, 0x32, 0x7d, 0xbb
+};
+
+static unsigned char tag_data_sha256[] = {
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x61,
+ 0x32, 0x61, 0x34, 0x33, 0x30, 0x66, 0x62, 0x36,
+ 0x33, 0x62, 0x32, 0x39, 0x34, 0x66, 0x38, 0x36,
+ 0x38, 0x61, 0x66, 0x34, 0x65, 0x66, 0x36, 0x63,
+ 0x63, 0x63, 0x39, 0x63, 0x33, 0x65, 0x38, 0x32,
+ 0x35, 0x36, 0x65, 0x33, 0x37, 0x30, 0x38, 0x35,
+ 0x39, 0x63, 0x65, 0x35, 0x37, 0x38, 0x61, 0x32,
+ 0x33, 0x38, 0x33, 0x37, 0x61, 0x63, 0x38, 0x35,
+ 0x33, 0x33, 0x37, 0x66, 0x35, 0x36, 0x32, 0x0a,
+ 0x74, 0x79, 0x70, 0x65, 0x20, 0x63, 0x6f, 0x6d,
+ 0x6d, 0x69, 0x74, 0x0a, 0x74, 0x61, 0x67, 0x20,
+ 0x76, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x0a, 0x74,
+ 0x61, 0x67, 0x67, 0x65, 0x72, 0x20, 0x43, 0x20,
+ 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
+ 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
+ 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
+ 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
+ 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
+ 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
+ 0x30, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20,
+ 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
+ 0x61, 0x67, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65,
+ 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x76, 0x30,
+ 0x2e, 0x30, 0x2e, 0x31, 0x0a, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x75, 0x6d,
+ 0x6d, 0x61, 0x72, 0x79, 0x0a, 0x0a, 0x54, 0x68,
+ 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x6f,
+ 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x6d, 0x65, 0x73,
+ 0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67,
+ 0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6f, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x72, 0x70,
+ 0x6f, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
+ 0x65, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x72, 0x6f,
+ 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d,
+ 0x6d, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x53, 0x69,
+ 0x67, 0x6e, 0x65, 0x64, 0x2d, 0x6f, 0x66, 0x2d,
+ 0x62, 0x79, 0x3a, 0x20, 0x41, 0x20, 0x55, 0x20,
+ 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78, 0x61,
+ 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x3e, 0x0a
+};
+#endif
+
static object_data tag = {
tag_bytes,
sizeof(tag_bytes),
"09d373e1dfdc16b129ceec6dd649739911541e05",
+ GIT_OID_SHA1,
"tag",
"test-objects/09",
"test-objects/09/d373e1dfdc16b129ceec6dd649739911541e05",
@@ -233,7 +536,24 @@ static object_data tag = {
sizeof(tag_data),
};
-/* zero == e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 */
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data tag_sha256 = {
+ tag_bytes_sha256,
+ sizeof(tag_bytes_sha256),
+ "f535d7595d5d0e5e530b5deb34542c96491fea300a1318036b605306548cb225",
+ GIT_OID_SHA256,
+ "tag",
+ "test-objects/f5",
+ "test-objects/f5/35d7595d5d0e5e530b5deb34542c96491fea300a1318036b605306548cb225",
+ tag_data_sha256,
+ sizeof(tag_data_sha256),
+};
+#endif
+
+/*
+ * zero == e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (sha1)
+ * 473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813 (sha256)
+ */
static unsigned char zero_bytes[] = {
0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
0x60, 0x00, 0x00, 0x09, 0xb0, 0x01, 0xf0,
@@ -247,6 +567,7 @@ static object_data zero = {
zero_bytes,
sizeof(zero_bytes),
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
+ GIT_OID_SHA1,
"blob",
"test-objects/e6",
"test-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391",
@@ -254,7 +575,24 @@ static object_data zero = {
0,
};
-/* two == 78981922613b2afb6025042ff6bd878ac1994e85 */
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data zero_sha256 = {
+ zero_bytes,
+ sizeof(zero_bytes),
+ "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
+ GIT_OID_SHA256,
+ "blob",
+ "test-objects/47",
+ "test-objects/47/3a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
+ zero_data,
+ 0,
+};
+#endif
+
+/*
+ * two == 78981922613b2afb6025042ff6bd878ac1994e85 (sha1)
+ * f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b (sha256)
+ */
static unsigned char two_bytes[] = {
0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
0x62, 0x48, 0xe4, 0x02, 0x00, 0x0e, 0x64, 0x02,
@@ -269,6 +607,7 @@ static object_data two = {
two_bytes,
sizeof(two_bytes),
"78981922613b2afb6025042ff6bd878ac1994e85",
+ GIT_OID_SHA1,
"blob",
"test-objects/78",
"test-objects/78/981922613b2afb6025042ff6bd878ac1994e85",
@@ -276,7 +615,24 @@ static object_data two = {
sizeof(two_data),
};
-/* some == fd8430bc864cfcd5f10e5590f8a447e01b942bfe */
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data two_sha256 = {
+ two_bytes,
+ sizeof(two_bytes),
+ "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b",
+ GIT_OID_SHA256,
+ "blob",
+ "test-objects/f8",
+ "test-objects/f8/625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b",
+ two_data,
+ sizeof(two_data),
+};
+#endif
+
+/*
+ * some == fd8430bc864cfcd5f10e5590f8a447e01b942bfe (sha1)
+ * 083c2b8b445640d171e7aa667b0b32007006f786711032ebb82931cca69cc15b (sha256)
+ */
static unsigned char some_bytes[] = {
0x78, 0x01, 0x7d, 0x54, 0xc1, 0x4e, 0xe3, 0x30,
0x10, 0xdd, 0x33, 0x5f, 0x31, 0xc7, 0x5d, 0x94,
@@ -514,9 +870,24 @@ static object_data some = {
some_bytes,
sizeof(some_bytes),
"fd8430bc864cfcd5f10e5590f8a447e01b942bfe",
+ GIT_OID_SHA1,
"blob",
"test-objects/fd",
"test-objects/fd/8430bc864cfcd5f10e5590f8a447e01b942bfe",
some_data,
sizeof(some_data),
};
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+static object_data some_sha256 = {
+ some_bytes,
+ sizeof(some_bytes),
+ "083c2b8b445640d171e7aa667b0b32007006f786711032ebb82931cca69cc15b",
+ GIT_OID_SHA256,
+ "blob",
+ "test-objects/08",
+ "test-objects/08/3c2b8b445640d171e7aa667b0b32007006f786711032ebb82931cca69cc15b",
+ some_data,
+ sizeof(some_data),
+};
+#endif
diff --git a/tests/libgit2/odb/mixed.c b/tests/libgit2/odb/mixed.c
index 87e945c83..19e6dcebf 100644
--- a/tests/libgit2/odb/mixed.c
+++ b/tests/libgit2/odb/mixed.c
@@ -5,7 +5,7 @@ static git_odb *_odb;
void test_odb_mixed__initialize(void)
{
- cl_git_pass(git_odb_open(&_odb, cl_fixture("duplicate.git/objects")));
+ cl_git_pass(git_odb__open(&_odb, cl_fixture("duplicate.git/objects"), NULL));
}
void test_odb_mixed__cleanup(void)
@@ -20,13 +20,13 @@ void test_odb_mixed__dup_oid(void) {
git_oid oid;
git_odb_object *obj;
- cl_git_pass(git_oid_fromstr(&oid, hex));
- cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, GIT_OID_HEXSZ));
+ cl_git_pass(git_oid__fromstr(&oid, hex, GIT_OID_SHA1));
+ cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, GIT_OID_SHA1_HEXSIZE));
git_odb_object_free(obj);
- cl_git_pass(git_odb_exists_prefix(NULL, _odb, &oid, GIT_OID_HEXSZ));
+ cl_git_pass(git_odb_exists_prefix(NULL, _odb, &oid, GIT_OID_SHA1_HEXSIZE));
- cl_git_pass(git_oid_fromstrn(&oid, short_hex, sizeof(short_hex) - 1));
+ cl_git_pass(git_oid__fromstrn(&oid, short_hex, sizeof(short_hex) - 1, GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, sizeof(short_hex) - 1));
git_odb_object_free(obj);
@@ -48,63 +48,63 @@ void test_odb_mixed__dup_oid_prefix_0(void) {
/* ambiguous in the same pack file */
strncpy(hex, "dea509d0", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
strncpy(hex, "dea509d09", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_git_pass(git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
cl_assert_equal_oid(&found, git_odb_object_id(obj));
git_odb_object_free(obj);
strncpy(hex, "dea509d0b", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
git_odb_object_free(obj);
/* ambiguous in different pack files */
strncpy(hex, "81b5bff5", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
strncpy(hex, "81b5bff5b", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_git_pass(git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
cl_assert_equal_oid(&found, git_odb_object_id(obj));
git_odb_object_free(obj);
strncpy(hex, "81b5bff5f", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
git_odb_object_free(obj);
/* ambiguous in pack file and loose */
strncpy(hex, "0ddeaded", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_assert_equal_i(
GIT_EAMBIGUOUS, git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
strncpy(hex, "0ddeaded9", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
cl_git_pass(git_odb_exists_prefix(&found, _odb, &oid, strlen(hex)));
cl_assert_equal_oid(&found, git_odb_object_id(obj));
git_odb_object_free(obj);
strncpy(hex, "0ddeadede", sizeof(hex));
- cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
+ cl_git_pass(git_oid__fromstrn(&oid, hex, strlen(hex), GIT_OID_SHA1));
cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
git_odb_object_free(obj);
}
@@ -170,7 +170,7 @@ static void setup_prefix_query(
size_t len = strlen(expand_id_test_data[i].lookup_id);
- git_oid_fromstrn(&id->id, expand_id_test_data[i].lookup_id, len);
+ git_oid__fromstrn(&id->id, expand_id_test_data[i].lookup_id, len, GIT_OID_SHA1);
id->length = (unsigned short)len;
id->type = expand_id_test_data[i].expected_type;
}
@@ -186,13 +186,13 @@ static void assert_found_objects(git_odb_expand_id *ids)
num = ARRAY_SIZE(expand_id_test_data);
for (i = 0; i < num; i++) {
- git_oid expected_id = {{0}};
+ git_oid expected_id = GIT_OID_SHA1_ZERO;
size_t expected_len = 0;
git_object_t expected_type = 0;
if (expand_id_test_data[i].expected_id) {
- git_oid_fromstr(&expected_id, expand_id_test_data[i].expected_id);
- expected_len = GIT_OID_HEXSZ;
+ git_oid__fromstr(&expected_id, expand_id_test_data[i].expected_id, GIT_OID_SHA1);
+ expected_len = GIT_OID_SHA1_HEXSIZE;
expected_type = expand_id_test_data[i].expected_type;
}
@@ -204,7 +204,7 @@ static void assert_found_objects(git_odb_expand_id *ids)
static void assert_notfound_objects(git_odb_expand_id *ids)
{
- git_oid expected_id = {{0}};
+ git_oid expected_id = GIT_OID_SHA1_ZERO;
size_t num, i;
num = ARRAY_SIZE(expand_id_test_data);
diff --git a/tests/libgit2/odb/packed.c b/tests/libgit2/odb/packed.c
index 3d502ed6d..b41041fc1 100644
--- a/tests/libgit2/odb/packed.c
+++ b/tests/libgit2/odb/packed.c
@@ -6,7 +6,7 @@ static git_odb *_odb;
void test_odb_packed__initialize(void)
{
- cl_git_pass(git_odb_open(&_odb, cl_fixture("testrepo.git/objects")));
+ cl_git_pass(git_odb__open(&_odb, cl_fixture("testrepo.git/objects"), NULL));
}
void test_odb_packed__cleanup(void)
@@ -23,7 +23,7 @@ void test_odb_packed__mass_read(void)
git_oid id;
git_odb_object *obj;
- cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
+ cl_git_pass(git_oid__fromstr(&id, packed_objects[i], GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &id) == 1);
cl_git_pass(git_odb_read(&obj, _odb, &id));
@@ -41,7 +41,7 @@ void test_odb_packed__read_header_0(void)
size_t len;
git_object_t type;
- cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
+ cl_git_pass(git_oid__fromstr(&id, packed_objects[i], GIT_OID_SHA1));
cl_git_pass(git_odb_read(&obj, _odb, &id));
cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
@@ -63,7 +63,7 @@ void test_odb_packed__read_header_1(void)
size_t len;
git_object_t type;
- cl_git_pass(git_oid_fromstr(&id, loose_objects[i]));
+ cl_git_pass(git_oid__fromstr(&id, loose_objects[i], GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &id) == 1);
diff --git a/tests/libgit2/odb/packed_one.c b/tests/libgit2/odb/packed_one.c
index 17cd4f760..7a1d3d913 100644
--- a/tests/libgit2/odb/packed_one.c
+++ b/tests/libgit2/odb/packed_one.c
@@ -10,7 +10,7 @@ void test_odb_packed_one__initialize(void)
{
git_odb_backend *backend = NULL;
- cl_git_pass(git_odb_new(&_odb));
+ cl_git_pass(git_odb__new(&_odb, NULL));
cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")));
cl_git_pass(git_odb_add_backend(_odb, backend, 1));
}
@@ -29,7 +29,7 @@ void test_odb_packed_one__mass_read(void)
git_oid id;
git_odb_object *obj;
- cl_git_pass(git_oid_fromstr(&id, packed_objects_one[i]));
+ cl_git_pass(git_oid__fromstr(&id, packed_objects_one[i], GIT_OID_SHA1));
cl_assert(git_odb_exists(_odb, &id) == 1);
cl_git_pass(git_odb_read(&obj, _odb, &id));
@@ -47,7 +47,7 @@ void test_odb_packed_one__read_header_0(void)
size_t len;
git_object_t type;
- cl_git_pass(git_oid_fromstr(&id, packed_objects_one[i]));
+ cl_git_pass(git_oid__fromstr(&id, packed_objects_one[i], GIT_OID_SHA1));
cl_git_pass(git_odb_read(&obj, _odb, &id));
cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
diff --git a/tests/libgit2/odb/sorting.c b/tests/libgit2/odb/sorting.c
index e027230fa..1010872f4 100644
--- a/tests/libgit2/odb/sorting.c
+++ b/tests/libgit2/odb/sorting.c
@@ -37,7 +37,7 @@ static git_odb *_odb;
void test_odb_sorting__initialize(void)
{
- cl_git_pass(git_odb_new(&_odb));
+ cl_git_pass(git_odb__new(&_odb, NULL));
}
void test_odb_sorting__cleanup(void)
@@ -79,12 +79,13 @@ void test_odb_sorting__override_default_backend_priority(void)
{
git_odb *new_odb;
git_odb_backend *loose, *packed, *backend;
+
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, 5));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, 3));
git_odb_backend_pack(&packed, "./testrepo.git/objects");
- git_odb_backend_loose(&loose, "./testrepo.git/objects", -1, 0, 0, 0);
+ git_odb__backend_loose(&loose, "./testrepo.git/objects", NULL);
- cl_git_pass(git_odb_open(&new_odb, cl_fixture("testrepo.git/objects")));
+ cl_git_pass(git_odb__open(&new_odb, cl_fixture("testrepo.git/objects"), NULL));
cl_assert_equal_sz(2, git_odb_num_backends(new_odb));
cl_git_pass(git_odb_get_backend(&backend, new_odb, 0));