diff options
author | Russell Belfer <rb@github.com> | 2013-04-19 23:48:33 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-04-21 22:50:55 +0400 |
commit | 83cc70d9fec5f81d07f9fc4133c9515527efb9af (patch) | |
tree | a3ddac356c641e6accf8396d08afbebb7bb52336 /src/odb.c | |
parent | 83041c711cd7d9fccb7a1327e642ce33f0705370 (diff) |
Move odb_backend implementors stuff into git2/sys
This moves some of the odb_backend stuff that is related to the
internals of an odb_backend implementation into include/git2/sys.
Some of the stuff related to streaming I left in include/git2
because it seemed like it would be reasonably needed by a normal
user who wanted to stream objects into and out of the ODB.
Also, I added APIs for traversing the list of backends so that
some of the tests would not need to access ODB internals.
Diffstat (limited to 'src/odb.c')
-rw-r--r-- | src/odb.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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; |