diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix/src/repository/graph.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/repository/graph.rs')
-rw-r--r-- | vendor/gix/src/repository/graph.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/vendor/gix/src/repository/graph.rs b/vendor/gix/src/repository/graph.rs index a1f6c7f89..f4f2b18cc 100644 --- a/vendor/gix/src/repository/graph.rs +++ b/vendor/gix/src/repository/graph.rs @@ -7,18 +7,34 @@ impl crate::Repository { /// Note that the commitgraph will be used if it is present and readable, but it won't be an error if it is corrupted. In that case, /// it will just not be used. /// + /// Note that a commitgraph is only allowed to be used if `core.commitGraph` is true (the default), and that configuration errors are + /// ignored as well. + /// /// ### Performance /// - /// Note that the [Graph][gix_revision::Graph] can be sensitive to various object database settings that may affect the performance + /// Note that the [Graph][gix_revwalk::Graph] can be sensitive to various object database settings that may affect the performance /// of the commit walk. - pub fn commit_graph<T>(&self) -> gix_revision::Graph<'_, T> { - gix_revision::Graph::new( + pub fn revision_graph<T>(&self) -> gix_revwalk::Graph<'_, T> { + gix_revwalk::Graph::new( |id, buf| { self.objects .try_find(id, buf) - .map(|r| r.and_then(|d| d.try_into_commit_iter())) + .map(|r| r.and_then(gix_object::Data::try_into_commit_iter)) }, - gix_commitgraph::at(self.objects.store_ref().path().join("info")).ok(), + self.config + .may_use_commit_graph() + .unwrap_or(true) + .then(|| gix_commitgraph::at(self.objects.store_ref().path().join("info")).ok()) + .flatten(), ) } + + /// Return a cache for commits and their graph structure, as managed by `git commit-graph`, for accelerating commit walks on + /// a low level. + /// + /// Note that [`revision_graph()`][crate::Repository::revision_graph()] should be preferred for general purpose walks that don't + /// rely on the actual commit cache to be present, while leveraging it if possible. + pub fn commit_graph(&self) -> Result<gix_commitgraph::Graph, gix_commitgraph::init::Error> { + gix_commitgraph::at(self.objects.store_ref().path().join("info")) + } } |