Skip to content

Commit 21bea0f

Browse files
committed
feat: impl From<entry::Mode> for gix_object::tree::EntryMode.
1 parent 223278d commit 21bea0f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: gix-index/src/entry/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ mod write;
1818

1919
use bitflags::bitflags;
2020

21-
// TODO: we essentially treat this as an enum withj the only exception being
22-
// that `FILE_EXECUTABLE.contains(FILE)` works might want to turn this into an
23-
// enum proper
21+
// TODO: we essentially treat this as an enum with the only exception being
22+
// that `FILE_EXECUTABLE.contains(FILE)` works might want to turn this into an
23+
// enum proper
2424
bitflags! {
2525
/// The kind of file of an entry.
2626
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

Diff for: gix-index/src/entry/mode.rs

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ impl Mode {
1111
*self == Self::DIR | Self::SYMLINK
1212
}
1313

14+
/// Convert this instance to a tree's entry mode, or return `None` if for some
15+
/// and unexpected reason the bitflags don't resemble any known entry-mode.
16+
pub fn to_tree_entry_mode(&self) -> Option<gix_object::tree::EntryMode> {
17+
gix_object::tree::EntryMode::try_from(self.bits()).ok()
18+
}
19+
1420
/// Compares this mode to the file system version ([`std::fs::symlink_metadata`])
1521
/// and returns the change needed to update this mode to match the file.
1622
///

0 commit comments

Comments
 (0)