Skip to content

Commit f445fe9

Browse files
committed
Add documentation for custom refdb/odb backends
1 parent 434c13f commit f445fe9

File tree

4 files changed

+51
-10
lines changed

4 files changed

+51
-10
lines changed

docs/backends.rst

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,41 @@
22
Backends
33
**********************************************************************
44

5-
There is some support for custom backends, but undocumented. See
6-
`<https://github.com/libgit2/pygit2/pull/690/commits>`_
5+
The use of custom backends for the git object database (odb) and reference
6+
database (refdb) are supported by pygit2.
77

8-
Documentation contributions are very welcome.
8+
.. contents:: Contents
9+
:local:
10+
11+
The OdbBackend class
12+
===================================
13+
14+
The OdbBackend class is subclassable and can be used to build a custom object
15+
database.
16+
17+
.. autoclass:: pygit2.OdbBackend
18+
:members:
19+
20+
Built-in OdbBackend implementations
21+
===================================
22+
23+
.. autoclass:: pygit2.OdbBackendLoose
24+
:members:
25+
26+
.. autoclass:: pygit2.OdbBackendPack
27+
:members:
28+
29+
The RefdbBackend class
30+
===================================
31+
32+
The RefdbBackend class is subclassable and can be used to build a custom
33+
reference database.
34+
35+
.. autoclass:: pygit2.RefdbBackend
36+
:members:
37+
38+
Built-in RefdbBackend implementations
39+
=====================================
40+
41+
.. autoclass:: pygit2.RefdbFsBackend
42+
:members:

docs/repository.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ Below there are some general attributes and methods:
5656
:members: ahead_behind, apply, create_reference, default_signature,
5757
descendant_of, describe, free, is_bare, is_empty, odb, path,
5858
path_is_ignored, reset, revert_commit, state_cleanup, workdir,
59-
write_archive
59+
write_archive, set_odb, set_refdb
6060

6161
The Repository constructor only takes one argument, the path of the
62-
repository to open.
62+
repository to open. Alternatively, constructing a repository with no
63+
arguments will create a repository with no backends. You can use this path
64+
to create repositories with custom backends. Note that most operations on
65+
the repository are considered invalid and may lead to undefined behavior if
66+
attempted before providing an odb and refdb via set_odb and set_refdb.
6367

6468
Example::
6569

@@ -73,5 +77,8 @@ The Odb class
7377
.. autoclass:: pygit2.Odb
7478
:members:
7579

76-
.. autoclass:: pygit2.OdbBackend
80+
The Refdb class
81+
===================================
82+
83+
.. autoclass:: pygit2.Refdb
7784
:members:

src/odb_backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ PyTypeObject OdbBackendPackType = {
772772
};
773773

774774
PyDoc_STRVAR(OdbBackendLoose__doc__,
775-
"OdbBackendLoose(objects_dir, compression_level,\n"
776-
" do_fsync, dir_mode=0, file_mode=0)\n"
775+
"OdbBackendLoose(objects_dir, compression_level,"
776+
" do_fsync, dir_mode=0, file_mode=0)\n"
777777
"\n"
778778
"Object database backend for loose objects.\n"
779779
"\n"

src/refdb_backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ RefdbBackend_lookup(RefdbBackend *self, PyObject *py_str)
582582
}
583583

584584
PyDoc_STRVAR(RefdbBackend_write__doc__,
585-
"write(ref: Reference, force: bool, who: Signature, message: str, \n"
586-
" old: oid, old_target: str)\n"
585+
"write(ref: Reference, force: bool, who: Signature, message: str, "
586+
"old: oid, old_target: str)\n"
587587
"\n"
588588
"Writes a new reference to the reference database.");
589589
// TODO: Better docs? libgit2 is scant on documentation for this, too.

0 commit comments

Comments
 (0)