diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-02-09 19:49:02 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-02-09 19:49:38 +0200 |
commit | d4b5a4e23a5d6bece88cebb2a53de68eddb4ca68 (patch) | |
tree | e881257e9f5ef0a9c94f0ba6974faa8fae0cbe87 /src/git2/odb.h | |
parent | 5a800efc42b5c58d06e0335348d75bde82af6ef7 (diff) | |
download | libgit2-d4b5a4e23a5d6bece88cebb2a53de68eddb4ca68.tar.gz |
Internal changes on the backend system
The priority value for different backends has been removed from the
public `git_odb_backend` struct. We handle that internally. The priority
value is specified on the `git_odb_add_alternate`.
This is convenient because it allows us to poll a backend twice with
different priorities without having to instantiate it twice.
We also differentiate between main backends and alternates; alternates have
lower priority and cannot be written to.
These changes come with some unit tests to make sure that the backend
sorting is consistent.
The libgit2 version has been bumped to 0.4.0.
This commit changes the external API:
CHANGED:
struct git_odb_backend
No longer has a `priority` attribute; priority for the backend
in managed internally by the library.
git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority)
Now takes an additional priority parameter, the priority that
will be given to the backend.
ADDED:
git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
Add a backend as an alternate. Alternate backends have always
lower priority than main backends, and writing is disabled on
them.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git2/odb.h')
-rw-r--r-- | src/git2/odb.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/git2/odb.h b/src/git2/odb.h index 2f2741135..0d285897c 100644 --- a/src/git2/odb.h +++ b/src/git2/odb.h @@ -79,7 +79,24 @@ GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir); * @paramm backend pointer to a git_odb_backend instance * @return 0 on sucess; error code otherwise */ -GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend); +GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority); + +/** + * Add a custom backend to an existing Object DB; this + * backend will work as an alternate. + * + * Alternate backends are always checked for objects *after* + * all the main backends have been exhausted. + * + * Writing is disabled on alternate backends. + * + * Read <odb_backends.h> for more information. + * + * @param odb database to add the backend to + * @paramm backend pointer to a git_odb_backend instance + * @return 0 on sucess; error code otherwise + */ +GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority); /** * Close an open object database. |