diff --git a/git-index/src/entry.rs b/git-index/src/entry.rs index 863fcbdf0f..5d15585971 100644 --- a/git-index/src/entry.rs +++ b/git-index/src/entry.rs @@ -61,6 +61,7 @@ pub(crate) mod at_rest { bitflags! { /// In-memory flags pub struct Flags: u32 { + const STAGE_MASK = 0x3000; // TODO: could we use the pathlen ourselves to save 8 bytes? And how to handle longer paths than that? 0 as sentinel maybe? const PATH_LEN = 0x0fff; const UPDATE = 1 << 16; @@ -88,6 +89,12 @@ bitflags! { } } +impl Flags { + pub fn stage(&self) -> u32 { + (*self & Flags::STAGE_MASK).bits >> 12 + } +} + #[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)] #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] pub struct Time { diff --git a/gitoxide-core/src/index.rs b/gitoxide-core/src/index.rs index 8a4e2d0a7b..369ad9f6c2 100644 --- a/gitoxide-core/src/index.rs +++ b/gitoxide-core/src/index.rs @@ -17,7 +17,13 @@ pub fn entries( for entry in file.entries() { writeln!( out, - "{}{:?} {} {}", + "{} {}{:?} {} {}", + match entry.flags.stage() { + 0 => "BASE ", + 1 => "OURS ", + 2 => "THEIRS ", + _ => "UNKNOWN", + }, if entry.flags.is_empty() { "".to_string() } else {