Move refdb_backend to include/git2/sys

This moves most of the refdb stuff over to the include/git2/sys
directory, with some minor shifts in function organization.

While I was making the necessary updates, I also removed the
trailing whitespace in a few files that I modified just because I
was there and it was bugging me.
This commit is contained in:
Russell Belfer 2013-04-19 17:17:44 -07:00
parent 9233b3de4e
commit 4dcd878019
9 changed files with 119 additions and 114 deletions

View File

@ -81,20 +81,6 @@ GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
*/ */
GIT_EXTERN(void) git_refdb_free(git_refdb *refdb); GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
/**
* Sets the custom backend to an existing reference DB
*
* Read <refdb_backends.h> for more information.
*
* @param refdb database to add the backend to
* @param backend pointer to a git_refdb_backend instance
* @param priority Value for ordering the backends queue
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_refdb_set_backend(
git_refdb *refdb,
git_refdb_backend *backend);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL

View File

@ -7,9 +7,9 @@
#ifndef INCLUDE_git_refdb_backend_h__ #ifndef INCLUDE_git_refdb_backend_h__
#define INCLUDE_git_refdb_backend_h__ #define INCLUDE_git_refdb_backend_h__
#include "common.h" #include "git2/common.h"
#include "types.h" #include "git2/types.h"
#include "oid.h" #include "git2/oid.h"
/** /**
* @file git2/refdb_backend.h * @file git2/refdb_backend.h
@ -103,6 +103,18 @@ GIT_EXTERN(int) git_refdb_backend_fs(
struct git_refdb_backend **backend_out, struct git_refdb_backend **backend_out,
git_repository *repo); git_repository *repo);
/**
* Sets the custom backend to an existing reference DB
*
* @param refdb database to add the backend to
* @param backend pointer to a git_refdb_backend instance
* @param priority Value for ordering the backends queue
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_refdb_set_backend(
git_refdb *refdb,
git_refdb_backend *backend);
GIT_END_DECL GIT_END_DECL
#endif #endif

View File

@ -7,15 +7,16 @@
#include "common.h" #include "common.h"
#include "posix.h" #include "posix.h"
#include "git2/object.h" #include "git2/object.h"
#include "git2/refs.h" #include "git2/refs.h"
#include "git2/refdb.h" #include "git2/refdb.h"
#include "git2/sys/refdb_backend.h"
#include "hash.h" #include "hash.h"
#include "refdb.h" #include "refdb.h"
#include "refs.h" #include "refs.h"
#include "git2/refdb_backend.h"
int git_refdb_new(git_refdb **out, git_repository *repo) int git_refdb_new(git_refdb **out, git_repository *repo)
{ {
git_refdb *db; git_refdb *db;

View File

@ -18,7 +18,7 @@
#include <git2/tag.h> #include <git2/tag.h>
#include <git2/object.h> #include <git2/object.h>
#include <git2/refdb.h> #include <git2/refdb.h>
#include <git2/refdb_backend.h> #include <git2/sys/refdb_backend.h>
GIT__USE_STRMAP; GIT__USE_STRMAP;

View File

@ -19,7 +19,6 @@
#include <git2/branch.h> #include <git2/branch.h>
#include <git2/refs.h> #include <git2/refs.h>
#include <git2/refdb.h> #include <git2/refdb.h>
#include <git2/refdb_backend.h>
GIT__USE_STRMAP; GIT__USE_STRMAP;

View File

@ -7,6 +7,8 @@
#ifndef INCLUDE_util_h__ #ifndef INCLUDE_util_h__
#define INCLUDE_util_h__ #define INCLUDE_util_h__
#include "common.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x)) #define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits)))) #define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))

View File

@ -1,12 +1,15 @@
#include "clar_libgit2.h" #include "clar_libgit2.h"
#include "refdb.h"
#include "repository.h" #include "buffer.h"
#include "posix.h"
#include "path.h"
#include "refs.h"
#include "testdb.h" #include "testdb.h"
#define TEST_REPO_PATH "testrepo" #define TEST_REPO_PATH "testrepo"
static git_repository *repo; static git_repository *repo;
static git_refdb_backend *refdb_backend;
int unlink_ref(void *payload, git_buf *file) int unlink_ref(void *payload, git_buf *file)
{ {
@ -51,15 +54,16 @@ int ref_file_foreach(git_repository *repo, int (* cb)(void *payload, git_buf *fi
void test_refdb_inmemory__initialize(void) void test_refdb_inmemory__initialize(void)
{ {
git_refdb *refdb;
git_buf repo_refs_dir = GIT_BUF_INIT; git_buf repo_refs_dir = GIT_BUF_INIT;
git_refdb *refdb;
git_refdb_backend *refdb_backend;
repo = cl_git_sandbox_init(TEST_REPO_PATH); repo = cl_git_sandbox_init(TEST_REPO_PATH);
cl_git_pass(git_repository_refdb(&refdb, repo)); cl_git_pass(git_repository_refdb(&refdb, repo));
cl_git_pass(refdb_backend_test(&refdb_backend, repo)); cl_git_pass(refdb_backend_test(&refdb_backend, repo));
cl_git_pass(git_refdb_set_backend(refdb, refdb_backend)); cl_git_pass(git_refdb_set_backend(refdb, refdb_backend));
git_refdb_free(refdb);
ref_file_foreach(repo, unlink_ref); ref_file_foreach(repo, unlink_ref);

View File

@ -1,10 +1,6 @@
#include "common.h"
#include "vector.h" #include "vector.h"
#include "util.h" #include "util.h"
#include <git2/refdb.h> #include "testdb.h"
#include <git2/refdb_backend.h>
#include <git2/errors.h>
#include <git2/repository.h>
typedef struct refdb_test_backend { typedef struct refdb_test_backend {
git_refdb_backend parent; git_refdb_backend parent;

View File

@ -1,3 +1,8 @@
#include <git2/errors.h>
#include <git2/repository.h>
#include <git2/refdb.h>
#include <git2/sys/refdb_backend.h>
int refdb_backend_test( int refdb_backend_test(
git_refdb_backend **backend_out, git_refdb_backend **backend_out,
git_repository *repo); git_repository *repo);