use git_hash::ObjectId;
use git_object::{bstr::BStr, tree};
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub enum Change {
Addition {
entry_mode: tree::EntryMode,
oid: ObjectId,
},
Deletion {
entry_mode: tree::EntryMode,
oid: ObjectId,
},
Modification {
previous_entry_mode: tree::EntryMode,
previous_oid: ObjectId,
entry_mode: tree::EntryMode,
oid: ObjectId,
},
}
#[derive(Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub enum Action {
Continue,
Cancel,
}
impl Default for Action {
fn default() -> Self {
Action::Continue
}
}
impl Action {
pub fn cancelled(&self) -> bool {
matches!(self, Action::Cancel)
}
}
pub trait Visit {
fn pop_front_tracked_path_and_set_current(&mut self);
fn push_back_tracked_path_component(&mut self, component: &BStr);
fn push_path_component(&mut self, component: &BStr);
fn pop_path_component(&mut self);
fn visit(&mut self, change: Change) -> Action;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn size_of_change() {
let actual = std::mem::size_of::<Change>();
assert!(
actual <= 46,
"{actual} <= 46: this type shouldn't grow without us knowing"
)
}
}