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
impl Graph
Access
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
impl Graph
Instantiate a Graph
from various sources.
Sourcepub fn at(path: &Path) -> Result<Self, Error>
pub fn at(path: &Path) -> Result<Self, Error>
Instantiate a commit graph from path
which may be a directory containing graph files or the graph file itself.
Sourcepub fn from_commit_graphs_dir(path: &Path) -> Result<Self, Error>
pub fn from_commit_graphs_dir(path: &Path) -> Result<Self, Error>
Instantiate a commit graph from the directory containing all of its files.
Sourcepub fn from_file(path: &Path) -> Result<Self, Error>
pub fn from_file(path: &Path) -> Result<Self, Error>
Instantiate a commit graph from a .git/objects/info/commit-graph
or
.git/objects/info/commit-graphs/graph-*.graph
file.
Sourcepub fn from_info_dir(info_dir: &Path) -> Result<Self, Error>
pub fn from_info_dir(info_dir: &Path) -> Result<Self, Error>
Instantiate a commit graph from an .git/objects/info
directory.
Source§impl Graph
impl Graph
Sourcepub fn verify_integrity<E>(
&self,
processor: impl FnMut(&Commit<'_>) -> Result<(), E>,
) -> Result<Outcome, Error<E>>where
E: Error + 'static,
pub fn verify_integrity<E>(
&self,
processor: impl FnMut(&Commit<'_>) -> Result<(), E>,
) -> Result<Outcome, Error<E>>where
E: Error + 'static,
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.