Commit 161d8a12 by Edward Thomson

sha256: wrap_odb supports SHA256

parent f1ef8ebe
......@@ -56,9 +56,19 @@ GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_work
*
* @param out pointer to the repo
* @param odb the object database to wrap
* @param oid_type the oid type of the object database
* @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
#ifdef GIT_EXPERIMENTAL_SHA256
GIT_EXTERN(int) git_repository_wrap_odb(
git_repository **out,
git_odb *odb,
git_oid_t oid_type);
#else
GIT_EXTERN(int) git_repository_wrap_odb(
git_repository **out,
git_odb *odb);
#endif
/**
* Look for a git repository and copy its path in the given buffer.
......@@ -536,7 +546,7 @@ GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
/**
* Get the path of the shared common directory for this repository.
*
*
* If the repository is bare, it is the root directory for the repository.
* If the repository is a worktree, it is the parent repo's gitdir.
* Otherwise, it is the gitdir.
......
......@@ -1145,21 +1145,39 @@ out:
return err;
}
int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb)
int git_repository__wrap_odb(
git_repository **out,
git_odb *odb,
git_oid_t oid_type)
{
git_repository *repo;
repo = repository_alloc();
GIT_ERROR_CHECK_ALLOC(repo);
repo->oid_type = GIT_OID_DEFAULT;
repo->oid_type = oid_type;
git_repository_set_odb(repo, odb);
*repo_out = repo;
*out = repo;
return 0;
}
#ifdef GIT_EXPERIMENTAL_SHA256
int git_repository_wrap_odb(
git_repository **out,
git_odb *odb,
git_oid_t oid_type)
{
return git_repository__wrap_odb(out, odb, oid_type);
}
#else
int git_repository_wrap_odb(git_repository **out, git_odb *odb)
{
return git_repository__wrap_odb(out, odb, GIT_OID_DEFAULT);
}
#endif
int git_repository_discover(
git_buf *out,
const char *start_path,
......
......@@ -190,6 +190,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo);
int git_repository_index__weakptr(git_index **out, git_repository *repo);
int git_repository__wrap_odb(
git_repository **out,
git_odb *odb,
git_oid_t oid_type);
/*
* Configuration map cache
*
......
......@@ -21,7 +21,7 @@ void test_odb_backend_loose__initialize(void)
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));
cl_git_pass(git_repository__wrap_odb(&_repo, _odb, GIT_OID_SHA1));
}
void test_odb_backend_loose__cleanup(void)
......
......@@ -16,7 +16,7 @@ void test_odb_backend_mempack__initialize(void)
cl_git_pass(git_mempack_new(&backend));
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));
cl_git_pass(git_repository__wrap_odb(&_repo, _odb, GIT_OID_SHA1));
}
void test_odb_backend_mempack__cleanup(void)
......
......@@ -2,6 +2,7 @@
#include "refs.h"
#include "vector.h"
#include "odb.h"
#include "repository.h"
static git_repository *repo;
......@@ -128,7 +129,7 @@ void test_refs_iterator__empty(void)
git_repository *empty;
cl_git_pass(git_odb__new(&odb, NULL));
cl_git_pass(git_repository_wrap_odb(&empty, odb));
cl_git_pass(git_repository__wrap_odb(&empty, odb, GIT_OID_SHA1));
cl_git_pass(git_reference_iterator_new(&iter, empty));
cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iter));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment