Commit 4dcd8780 by Russell Belfer

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.
parent 9233b3de
......@@ -81,20 +81,6 @@ GIT_EXTERN(int) git_refdb_compress(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
......
......@@ -7,9 +7,9 @@
#ifndef INCLUDE_git_refdb_backend_h__
#define INCLUDE_git_refdb_backend_h__
#include "common.h"
#include "types.h"
#include "oid.h"
#include "git2/common.h"
#include "git2/types.h"
#include "git2/oid.h"
/**
* @file git2/refdb_backend.h
......@@ -103,6 +103,18 @@ GIT_EXTERN(int) git_refdb_backend_fs(
struct git_refdb_backend **backend_out,
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
#endif
......@@ -7,15 +7,16 @@
#include "common.h"
#include "posix.h"
#include "git2/object.h"
#include "git2/refs.h"
#include "git2/refdb.h"
#include "git2/sys/refdb_backend.h"
#include "hash.h"
#include "refdb.h"
#include "refs.h"
#include "git2/refdb_backend.h"
int git_refdb_new(git_refdb **out, git_repository *repo)
{
git_refdb *db;
......
......@@ -18,7 +18,7 @@
#include <git2/tag.h>
#include <git2/object.h>
#include <git2/refdb.h>
#include <git2/refdb_backend.h>
#include <git2/sys/refdb_backend.h>
GIT__USE_STRMAP;
......
......@@ -19,7 +19,6 @@
#include <git2/branch.h>
#include <git2/refs.h>
#include <git2/refdb.h>
#include <git2/refdb_backend.h>
GIT__USE_STRMAP;
......
......@@ -7,6 +7,8 @@
#ifndef INCLUDE_util_h__
#define INCLUDE_util_h__
#include "common.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
......
#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"
#define TEST_REPO_PATH "testrepo"
static git_repository *repo;
static git_refdb_backend *refdb_backend;
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)
{
git_refdb *refdb;
git_buf repo_refs_dir = GIT_BUF_INIT;
git_refdb *refdb;
git_refdb_backend *refdb_backend;
repo = cl_git_sandbox_init(TEST_REPO_PATH);
cl_git_pass(git_repository_refdb(&refdb, repo));
cl_git_pass(refdb_backend_test(&refdb_backend, repo));
cl_git_pass(git_refdb_set_backend(refdb, refdb_backend));
git_refdb_free(refdb);
ref_file_foreach(repo, unlink_ref);
......
#include "common.h"
#include "vector.h"
#include "util.h"
#include <git2/refdb.h>
#include <git2/refdb_backend.h>
#include <git2/errors.h>
#include <git2/repository.h>
#include "testdb.h"
typedef struct refdb_test_backend {
git_refdb_backend parent;
......
#include <git2/errors.h>
#include <git2/repository.h>
#include <git2/refdb.h>
#include <git2/sys/refdb_backend.h>
int refdb_backend_test(
git_refdb_backend **backend_out,
git_repository *repo);
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