mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
repo: don't require oid_type to wrap_odb
The `wrap_odb` function doesn't need to know the OID types in the object database; the object database already knows the type.
This commit is contained in:
@@ -53,15 +53,6 @@ GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
|
||||
*/
|
||||
GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_worktree *wt);
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
|
||||
GIT_EXTERN(int) git_repository_wrap_odb(
|
||||
git_repository **out,
|
||||
git_odb *odb,
|
||||
const git_odb_options *opts);
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Create a "fake" repository to wrap an object database
|
||||
*
|
||||
@@ -77,8 +68,6 @@ 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.
|
||||
* The lookup start from base_path and walk across parent directories
|
||||
|
||||
@@ -1221,19 +1221,15 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
int git_repository__wrap_odb(
|
||||
git_repository **out,
|
||||
git_odb *odb,
|
||||
git_oid_t oid_type)
|
||||
int git_repository_wrap_odb(git_repository **out, git_odb *odb)
|
||||
{
|
||||
git_repository *repo;
|
||||
|
||||
GIT_ASSERT_ARG(git_oid_type_is_valid(oid_type));
|
||||
|
||||
repo = repository_alloc();
|
||||
GIT_ERROR_CHECK_ALLOC(repo);
|
||||
|
||||
repo->oid_type = oid_type;
|
||||
GIT_ASSERT(git_oid_type_is_valid(odb->options.oid_type));
|
||||
repo->oid_type = odb->options.oid_type;
|
||||
|
||||
git_repository_set_odb(repo, odb);
|
||||
*out = repo;
|
||||
@@ -1241,21 +1237,6 @@ int git_repository__wrap_odb(
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
int git_repository_wrap_odb(
|
||||
git_repository **out,
|
||||
git_odb *odb,
|
||||
const git_odb_options *opts)
|
||||
{
|
||||
return git_repository__wrap_odb(out, odb, opts ? opts->oid_type : GIT_OID_DEFAULT);
|
||||
}
|
||||
#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,
|
||||
|
||||
@@ -199,11 +199,6 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo);
|
||||
int git_repository_grafts__weakptr(git_grafts **out, git_repository *repo);
|
||||
int git_repository_shallow_grafts__weakptr(git_grafts **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, GIT_OID_SHA1));
|
||||
cl_git_pass(git_repository_wrap_odb(&_repo, _odb));
|
||||
}
|
||||
|
||||
void test_odb_backend_loose__cleanup(void)
|
||||
|
||||
@@ -15,7 +15,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, GIT_OID_SHA1));
|
||||
cl_git_pass(git_repository_wrap_odb(&_repo, _odb));
|
||||
}
|
||||
|
||||
void test_odb_backend_mempack__cleanup(void)
|
||||
|
||||
@@ -129,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, GIT_OID_SHA1));
|
||||
cl_git_pass(git_repository_wrap_odb(&empty, odb));
|
||||
|
||||
cl_git_pass(git_reference_iterator_new(&iter, empty));
|
||||
cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iter));
|
||||
|
||||
Reference in New Issue
Block a user