Skip to content

various improvements #2000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gix/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ pub mod merge_base_octopus {
}
}

///
#[cfg(feature = "revision")]
pub mod merge_bases_many {
/// The error returned by [Repository::merge_bases_many()](crate::Repository::merge_bases_many()).
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
OpenCache(#[from] crate::repository::commit_graph_if_enabled::Error),
#[error(transparent)]
MergeBase(#[from] gix_revision::merge_base::Error),
}
}

///
#[cfg(feature = "merge")]
pub mod tree_merge_options {
Expand Down
24 changes: 21 additions & 3 deletions gix/src/repository/revision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ impl crate::Repository {
Ok(bases[0].attach(self))
}

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

/// 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).
///
/// # Performance
///
/// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to speed up repeated commit lookups, and consider
/// using [`merge_bases_many_with_graph()`](Self::merge_bases_many_with_graph) for consecutive calls.
#[doc(alias = "git2")]
#[cfg(feature = "revision")]
pub fn merge_bases_many(
&self,
one: impl Into<gix_hash::ObjectId>,
others: &[gix_hash::ObjectId],
) -> Result<Vec<Id<'_>>, crate::repository::merge_bases_many::Error> {
let cache = self.commit_graph_if_enabled()?;
let mut graph = self.revision_graph(cache.as_ref());
Ok(self.merge_bases_many_with_graph(one, others, &mut graph)?)
}

/// Return the best merge-base among all `commits`, or fail if `commits` yields no commit or no merge-base was found.
///
/// Use `graph` to speed up repeated calls.
Expand Down
Loading