Skip to content

Commit

Permalink
simple printing of basic entry information (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 23, 2022
1 parent 9ea98fd commit 329538b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions git-index/src/entry.rs
Expand Up @@ -88,11 +88,15 @@ bitflags! {
}
}

#[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Time {
pub secs: u32,
pub nsecs: u32,
}

#[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Stat {
pub mtime: Time,
pub ctime: Time,
Expand Down
18 changes: 16 additions & 2 deletions gitoxide-core/src/index.rs
Expand Up @@ -4,7 +4,7 @@ use std::path::Path;
#[allow(unused)]
pub fn entries(
index_path: impl AsRef<Path>,
out: impl std::io::Write,
mut out: impl std::io::Write,
object_hash: git::hash::Kind,
) -> anyhow::Result<()> {
let file = git::index::File::at(
Expand All @@ -14,5 +14,19 @@ pub fn entries(
..Default::default()
},
)?;
todo!("print entries")
for entry in file.entries() {
writeln!(
out,
"{}{:?} {} {}",
if entry.flags.is_empty() {
"".to_string()
} else {
format!("{:?} ", entry.flags)
},
entry.mode,
entry.id,
entry.path(&file.state)
)?;
}
Ok(())
}

0 comments on commit 329538b

Please sign in to comment.