bitflags::bitflags! {
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
pub struct Flags: u8 {
const COMMIT1 = 1 << 0;
const COMMIT2 = 1 << 1;
const STALE = 1 << 2;
const RESULT = 1 << 3;
}
}
pub type Error = Simple;
#[derive(Debug)]
pub struct Simple(pub &'static str);
impl std::fmt::Display for Simple {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.0)
}
}
impl std::error::Error for Simple {}
pub(crate) mod function;
mod octopus {
use gix_hash::ObjectId;
use gix_revwalk::{graph, Graph};
use crate::merge_base::{Error, Flags};
pub fn octopus(
mut first: ObjectId,
others: &[ObjectId],
graph: &mut Graph<'_, '_, graph::Commit<Flags>>,
) -> Result<Option<ObjectId>, Error> {
for other in others {
if let Some(next) =
crate::merge_base(first, std::slice::from_ref(other), graph)?.map(|bases| *bases.first())
{
first = next;
} else {
return Ok(None);
}
}
Ok(Some(first))
}
}
pub use octopus::octopus;