pub struct OdbBuilder { /* private fields */ }Expand description
Configure and construct an Odb with a pluggable primary backend.
Implementations§
Source§impl OdbBuilder
impl OdbBuilder
Sourcepub fn files(objects_dir: impl AsRef<Path>) -> Self
pub fn files(objects_dir: impl AsRef<Path>) -> Self
Default files-backed layout rooted at objects_dir (the repository’s objects/ tree).
When passed to RepositoryBuilder::odb_builder,
any spelling of the repository’s objects/ directory is accepted: a path through
symlinks, or a relative path (resolved against the environment’s current directory).
With a custom Self::primary the directory need not exist, but it must still name
the repository’s objects/ directory.
Sourcepub fn primary(self, store: Arc<dyn WritableObjectStore>) -> Self
pub fn primary(self, store: Arc<dyn WritableObjectStore>) -> Self
Replace the default super::store::FilesSource primary with a custom store.
Writes and primary reads go through this backend, including commits, staging
(crate::porcelain::add::stage), merges, stash, notes, and bundle creation.
Repository::fsck validates the objects this
store lists. Received packs are written into it object by object:
ingest_received_pack and
Bundle::unbundle resolve every delta and call
WritableObjectStore::write instead of installing a pack under objects/pack/.
Remote::fetch, Remote::push,
pull, bundles, and clone_into read and write objects through
the custom primary. Partial-clone filters (operation: "partial fetch") and filesystem
maintenance still refuse when they need on-disk pack layout:
- maintenance:
Odb::gc,Odb::write_commit_graph, repack, MIDX, and pack helpers
History walks never read commit-graph files from objects/ for a custom primary: such
a file describes the files layout, not this store. To give walks a commit-graph, build
one with crate::maintenance::build_commit_graph, persist its bytes in the store, and
attach it with Self::commit_graph when opening the repository.
The store’s ObjectStore::hash_algo must match the repository’s object format:
RepositoryBuilder::open fails with
Error::ObjectFormatMismatch otherwise. Self::build does not check, since it
has no repository config to compare against.
Sourcepub fn push_read_source(self, store: Arc<dyn ObjectStore>) -> Self
pub fn push_read_source(self, store: Arc<dyn ObjectStore>) -> Self
Append a read-only store consulted after the primary and before alternates.
Like Self::primary, its hash algorithm must match the repository’s object format
or RepositoryBuilder::open fails with
Error::ObjectFormatMismatch.
Sourcepub fn commit_graph(self, chain: Arc<CommitGraphChain>) -> Self
pub fn commit_graph(self, chain: Arc<CommitGraphChain>) -> Self
Attach a commit-graph for history walks to consult, for any primary store.
Rev-list, merge-base, ancestry checks, rev-parse navigation, blame and path-limited log
read parents, root trees, committer dates and generation numbers from chain, and test
changed-path Bloom filters when it has them, instead of reading commit objects. Commits
missing from the graph (written after it was built) are read from the store as usual,
so a graph that covers only older history stays correct.
An attached graph replaces any graph file under objects/info/. It is trusted, not
checked against the store: every commit it lists must be in this database with exactly
the parents and tree it records, which holds for a graph
crate::maintenance::build_commit_graph built from this repository. Build it with
CommitGraphChain::from_bytes.
The graph’s CommitGraphChain::hash_algo must match the repository’s object format,
or RepositoryBuilder::open fails with
Error::ObjectFormatMismatch.
Sourcepub fn alternates(self, enabled: bool) -> Self
pub fn alternates(self, enabled: bool) -> Self
When false, skip info/alternates, environment alternates, and submodule object dirs.
Sourcepub fn objects_dir(&self) -> &Path
pub fn objects_dir(&self) -> &Path
objects/ directory this builder targets.
Sourcepub fn build(self) -> Odb
pub fn build(self) -> Odb
Construct an Odb handle (attach Odb::with_config_git_dir when opening a repository).