Skip to content

Commit

Permalink
Derive Debug for IndexEntry, IndexTime, and Time (#762)
Browse files Browse the repository at this point in the history
Sometimes it's useful to quickly dump an IndexEntry for debugging;
having a `Debug` impl helps. Derive `Debug` for several time-related
types (as well as the underlying structures in libgit2-sys).
  • Loading branch information
joshtriplett committed Nov 8, 2021
1 parent 4461b17 commit 2afab9f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libgit2-sys/lib.rs
Expand Up @@ -143,7 +143,7 @@ pub struct git_signature {
}

#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct git_time {
pub time: git_time_t,
pub offset: c_int,
Expand Down Expand Up @@ -817,7 +817,7 @@ pub const GIT_INDEX_ENTRY_STAGEMASK: u16 = 0x3000;
pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12;

#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct git_index_time {
pub seconds: i32,
pub nanoseconds: u32,
Expand Down
1 change: 1 addition & 0 deletions src/index.rs
Expand Up @@ -54,6 +54,7 @@ pub type IndexMatchedPath<'a> = dyn FnMut(&Path, &[u8]) -> i32 + 'a;
/// All fields of an entry are public for modification and inspection. This is
/// also how a new index entry is created.
#[allow(missing_docs)]
#[derive(Debug)]
pub struct IndexEntry {
pub ctime: IndexTime,
pub mtime: IndexTime,
Expand Down
4 changes: 2 additions & 2 deletions src/time.rs
Expand Up @@ -6,13 +6,13 @@ use crate::raw;
use crate::util::Binding;

/// Time in a signature
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Time {
raw: raw::git_time,
}

/// Time structure used in a git index entry.
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct IndexTime {
raw: raw::git_index_time,
}
Expand Down

0 comments on commit 2afab9f

Please sign in to comment.