Skip to content

Commit fdfb239

Browse files
authored
Merge pull request #2000 from GitoxideLabs/improvements
various improvements
2 parents 33c4d6b + f687cb1 commit fdfb239

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

gix/src/repository/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,20 @@ pub mod merge_base_octopus {
219219
}
220220
}
221221

222+
///
223+
#[cfg(feature = "revision")]
224+
pub mod merge_bases_many {
225+
/// The error returned by [Repository::merge_bases_many()](crate::Repository::merge_bases_many()).
226+
#[derive(Debug, thiserror::Error)]
227+
#[allow(missing_docs)]
228+
pub enum Error {
229+
#[error(transparent)]
230+
OpenCache(#[from] crate::repository::commit_graph_if_enabled::Error),
231+
#[error(transparent)]
232+
MergeBase(#[from] gix_revision::merge_base::Error),
233+
}
234+
}
235+
222236
///
223237
#[cfg(feature = "merge")]
224238
pub mod tree_merge_options {

gix/src/repository/revision.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ impl crate::Repository {
8282
Ok(bases[0].attach(self))
8383
}
8484

85-
/// Obtain all merge-bases between commit `one` and `others`, or an empty list if there is none, providing a
86-
/// commit-graph `graph` to potentially greatly accelerate the operation.
85+
/// Get all merge-bases between commit `one` and `others`, or an empty list if there is none, providing a
86+
/// commit-graph `graph` to potentially greatly speed up the operation.
8787
///
8888
/// # Performance
89-
/// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to accelerate repeated commit lookups.
89+
/// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to speed up repeated commit lookups.
9090
#[doc(alias = "merge_bases_many", alias = "git2")]
9191
#[cfg(feature = "revision")]
9292
pub fn merge_bases_many_with_graph(
@@ -104,6 +104,24 @@ impl crate::Repository {
104104
.collect())
105105
}
106106

107+
/// Like [`merge_bases_many_with_graph()`](Self::merge_bases_many_with_graph), but without the ability to speed up consecutive calls with a [graph](gix_revwalk::Graph).
108+
///
109+
/// # Performance
110+
///
111+
/// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to speed up repeated commit lookups, and consider
112+
/// using [`merge_bases_many_with_graph()`](Self::merge_bases_many_with_graph) for consecutive calls.
113+
#[doc(alias = "git2")]
114+
#[cfg(feature = "revision")]
115+
pub fn merge_bases_many(
116+
&self,
117+
one: impl Into<gix_hash::ObjectId>,
118+
others: &[gix_hash::ObjectId],
119+
) -> Result<Vec<Id<'_>>, crate::repository::merge_bases_many::Error> {
120+
let cache = self.commit_graph_if_enabled()?;
121+
let mut graph = self.revision_graph(cache.as_ref());
122+
Ok(self.merge_bases_many_with_graph(one, others, &mut graph)?)
123+
}
124+
107125
/// Return the best merge-base among all `commits`, or fail if `commits` yields no commit or no merge-base was found.
108126
///
109127
/// Use `graph` to speed up repeated calls.

0 commit comments

Comments
 (0)