summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-04-22 04:06:11 -0700
committerVicent Martí <vicent@github.com>2013-04-22 04:06:11 -0700
commitf063a75882769cb6fc652de425ac16ba4b88b616 (patch)
tree8c9f02ac9b2e46846367098d3b6328c01cac7781 /src/odb.c
parentbfb4facb3a5e0b650811560fc49d27247fd9d85d (diff)
parent21ca045100337bcb2905a20a72d42721d18871f9 (diff)
downloadlibgit2-f063a75882769cb6fc652de425ac16ba4b88b616.tar.gz
Merge pull request #1485 from libgit2/include-git2-sys
Create include/git2/sys and move backend APIs there
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/odb.c b/src/odb.c
index c98df247c..ecdaf7ac2 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -8,6 +8,7 @@
#include "common.h"
#include <zlib.h>
#include "git2/object.h"
+#include "git2/sys/odb_backend.h"
#include "fileops.h"
#include "hash.h"
#include "odb.h"
@@ -403,6 +404,27 @@ int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
return add_backend_internal(odb, backend, priority, 1);
}
+size_t git_odb_num_backends(git_odb *odb)
+{
+ assert(odb);
+ return odb->backends.length;
+}
+
+int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
+{
+ backend_internal *internal;
+
+ assert(odb && odb);
+ internal = git_vector_get(&odb->backends, pos);
+
+ if (internal && internal->backend) {
+ *out = internal->backend;
+ return 0;
+ }
+
+ return GIT_ENOTFOUND;
+}
+
static int add_default_backends(git_odb *db, const char *objects_dir, int as_alternates, int alternate_depth)
{
git_odb_backend *loose, *packed;