gix_revision

Function merge_base

source
pub fn merge_base(
    first: ObjectId,
    others: &[ObjectId],
    graph: &mut Graph<'_, '_, Commit<Flags>>,
) -> Result<Option<Vec<ObjectId>>, Error>
Available on crate feature merge_base only.
Expand description

Given a commit at first id, traverse the commit graph and return all possible merge-base between it and others, sorted from best to worst. Returns None if there is no merge-base as first and others don’t share history. If others is empty, Some(first) is returned.

Note that this function doesn’t do any work if first is contained in others, which is when first will be returned as only merge-base right away. This is even the case if some commits of others are disjoint.

§Performance

For repeated calls, be sure to re-use graph as its content will be kept and reused for a great speed-up. The contained flags will automatically be cleared.