pub struct Graph { /* private fields */ }Expand description
A complete commit graph.
The data in the commit graph may come from a monolithic objects/info/commit-graph file, or it
may come from one or more objects/info/commit-graphs/graph-*.graph files. These files are
generated via git commit-graph write ... commands.
Implementations§
Source§impl Graph
Access
impl Graph
Access
Sourcepub fn object_hash(&self) -> Kind
pub fn object_hash(&self) -> Kind
The kind of hash used in this Graph.
Note that it is always conforming to the hash used in the owning repository.
Sourcepub fn commit_by_id(&self, id: impl AsRef<oid>) -> Option<Commit<'_>>
pub fn commit_by_id(&self, id: impl AsRef<oid>) -> Option<Commit<'_>>
Returns the commit matching the given id.
Sourcepub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>>
pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>>
Iterate over commits in unsorted order.
Sourcepub fn iter_ids(&self) -> impl Iterator<Item = &oid>
pub fn iter_ids(&self) -> impl Iterator<Item = &oid>
Iterate over commit IDs in unsorted order.
Sourcepub fn lookup(&self, id: impl AsRef<oid>) -> Option<Position>
pub fn lookup(&self, id: impl AsRef<oid>) -> Option<Position>
Translate the given id to its position in the file.
Sourcepub fn num_commits(&self) -> u32
pub fn num_commits(&self) -> u32
Returns the number of commits stored in this file.
Source§impl Graph
Instantiate a Graph from various sources.
impl Graph
Instantiate a Graph from various sources.
Sourcepub fn at(
path: &Path,
object_hash: Kind,
alloc_limit_bytes: Option<usize>,
) -> Result<Self>
pub fn at( path: &Path, object_hash: Kind, alloc_limit_bytes: Option<usize>, ) -> Result<Self>
Instantiate a commit graph from path which may be a directory containing graph files or the graph file itself.
Chain entries and graph files must use object_hash, typically the repository’s hash kind.
Mismatches are reported as corruption.
alloc_limit_bytes bounds a conservative capacity estimate for parent buffers derived from
each file’s EDGE chunk, including geometric buffer growth. None disables the limit.
The mapped graph data itself is not allocated on the heap.
Filesystem errors retain their std::io::Error source, including when path does not exist.
Sourcepub fn from_commit_graphs_dir(path: &Path, object_hash: Kind) -> Result<Self>
pub fn from_commit_graphs_dir(path: &Path, object_hash: Kind) -> Result<Self>
Instantiate a commit graph from the directory containing all of its files.
Chain entries and graph files must use object_hash.
Sourcepub fn from_file(path: &Path, object_hash: Kind) -> Result<Self>
pub fn from_file(path: &Path, object_hash: Kind) -> Result<Self>
Instantiate a commit graph from a .git/objects/info/commit-graph or
.git/objects/info/commit-graphs/graph-*.graph file.
The graph file must use object_hash.
Sourcepub fn from_info_dir(info_dir: &Path, object_hash: Kind) -> Result<Self>
pub fn from_info_dir(info_dir: &Path, object_hash: Kind) -> Result<Self>
Instantiate a commit graph from an .git/objects/info directory.
Chain entries and graph files must use object_hash.
Source§impl Graph
impl Graph
Sourcepub fn verify_integrity<E>(
&self,
processor: impl FnMut(&Commit<'_>) -> Result<(), E>,
) -> Result<Outcome>
pub fn verify_integrity<E>( &self, processor: impl FnMut(&Commit<'_>) -> Result<(), E>, ) -> Result<Outcome>
Traverse all commits in the graph and call processor(&commit) -> Result<(), E> on it while verifying checksums.
When processor returns an error, the entire verification is stopped and the error returned.