use std::borrow::Cow;
use bstr::BStr;
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("Cannot diff indices that contain sparse entries")]
IsSparse,
#[error("Unmerged entries aren't allowed in the left-hand index, only in the right-hand index")]
LhsHasUnmerged,
#[error("The callback indicated failure")]
Callback(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("Failure during rename tracking")]
RenameTracking(#[from] crate::rewrites::tracker::emit::Error),
}
#[derive(Default, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub enum Action {
#[default]
Continue,
Cancel,
}
pub struct RewriteOptions<'a, Find>
where
Find: gix_object::FindObjectOrHeader,
{
pub resource_cache: &'a mut crate::blob::Platform,
pub find: &'a Find,
pub rewrites: crate::Rewrites,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ChangeRef<'lhs, 'rhs> {
Addition {
location: Cow<'rhs, BStr>,
index: usize,
entry_mode: gix_index::entry::Mode,
id: Cow<'rhs, gix_hash::oid>,
},
Deletion {
location: Cow<'lhs, BStr>,
index: usize,
entry_mode: gix_index::entry::Mode,
id: Cow<'rhs, gix_hash::oid>,
},
Modification {
location: Cow<'rhs, BStr>,
previous_index: usize,
previous_entry_mode: gix_index::entry::Mode,
previous_id: Cow<'lhs, gix_hash::oid>,
index: usize,
entry_mode: gix_index::entry::Mode,
id: Cow<'rhs, gix_hash::oid>,
},
Rewrite {
source_location: Cow<'lhs, BStr>,
source_index: usize,
source_entry_mode: gix_index::entry::Mode,
source_id: Cow<'lhs, gix_hash::oid>,
location: Cow<'rhs, BStr>,
index: usize,
entry_mode: gix_index::entry::Mode,
id: Cow<'rhs, gix_hash::oid>,
copy: bool,
},
}
pub type Change = ChangeRef<'static, 'static>;
mod change;
pub(super) mod function;