Skip to content

Commit

Permalink
Also print stage of entries (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 23, 2022
1 parent 329538b commit 003515f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions git-index/src/entry.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion gitoxide-core/src/index.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 003515f

Please sign in to comment.