|
6 | 6 | #include <cppgit2/oid.hpp> |
7 | 7 | #include <cppgit2/ownership.hpp> |
8 | 8 | #include <git2.h> |
| 9 | +#include <tuple> |
9 | 10 | #include <utility> |
10 | 11 | #include <vector> |
11 | | -#include <tuple> |
12 | 12 |
|
13 | 13 | namespace cppgit2 { |
14 | 14 |
|
@@ -40,6 +40,25 @@ class odb : public libgit2_api { |
40 | 40 | git_odb_backend *c_ptr_; |
41 | 41 | }; |
42 | 42 |
|
| 43 | + // Add a custom backend to an existing Object DB; this backend will work as an |
| 44 | + // alternate. |
| 45 | + // |
| 46 | + // Alternate backends are always checked for objects after all the main |
| 47 | + // backends have been exhausted. The backends are checked in relative |
| 48 | + // ordering, based on the value of the priority parameter. Writing is disabled |
| 49 | + // on alternate backends. |
| 50 | + void add_alternate_backend(const backend &backend, int priority); |
| 51 | + |
| 52 | + // Add a custom backend to an existing Object DB |
| 53 | + // The backends are checked in relative ordering, based on the value of the priority parameter. |
| 54 | + void add_backend(const backend &backend, int priority); |
| 55 | + |
| 56 | + // Add an on-disk alternate to an existing Object DB. |
| 57 | + // Note that the added path must point to an objects, not to a full repository, to use it as an alternate store. |
| 58 | + // Alternate backends are always checked for objects after all the main backends have been exhausted. |
| 59 | + // Writing is disabled on alternate backends. |
| 60 | + void add_disk_alternate_backend(const std::string &path); |
| 61 | + |
43 | 62 | // Create a backend for loose objects |
44 | 63 | static backend |
45 | 64 | create_backend_for_loose_objects(const std::string &objects_dir, |
@@ -298,15 +317,19 @@ class odb : public libgit2_api { |
298 | 317 | // all backends. |
299 | 318 | // |
300 | 319 | // Returns {stream, length of object, type of object} |
301 | | - std::tuple<stream, size_t, cppgit2::object::object_type> open_rstream(const oid &id); |
| 320 | + std::tuple<stream, size_t, cppgit2::object::object_type> |
| 321 | + open_rstream(const oid &id); |
302 | 322 |
|
303 | 323 | // Open a stream to write an object into the ODB |
304 | 324 | // The type and final length of the object must be specified when opening the |
305 | 325 | // stream. The returned stream will be of type GIT_STREAM_WRONLY, and it won't |
306 | 326 | // be effective until git_odb_stream_finalize_write is called and returns |
307 | 327 | // without an error |
308 | 328 | stream open_wstream(cppgit2::object::object_size size, |
309 | | - cppgit2::object::object_type type); |
| 329 | + cppgit2::object::object_type type); |
| 330 | + |
| 331 | + // Write an object directly into the ODB |
| 332 | + oid write(const void *data, size_t length, cppgit2::object::object_type type); |
310 | 333 |
|
311 | 334 | // Access libgit2 C ptr |
312 | 335 | const git_odb *c_ptr() const; |
|
0 commit comments