Skip to content

Commit de4375a

Browse files
committed
feat: Add From<gix_object::tree::EntryKind> for entry::Mode
That way it's easier to add new entries to the index.
1 parent 668cb12 commit de4375a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gix-index/src/entry/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,21 @@ mod access {
107107
mod _impls {
108108
use std::cmp::Ordering;
109109

110+
use crate::{entry, Entry, State};
110111
use bstr::BStr;
111-
112-
use crate::{Entry, State};
112+
use gix_object::tree::EntryKind;
113+
114+
impl From<EntryKind> for entry::Mode {
115+
fn from(value: EntryKind) -> Self {
116+
match value {
117+
EntryKind::Tree => entry::Mode::DIR,
118+
EntryKind::Blob => entry::Mode::FILE,
119+
EntryKind::BlobExecutable => entry::Mode::FILE_EXECUTABLE,
120+
EntryKind::Link => entry::Mode::SYMLINK,
121+
EntryKind::Commit => entry::Mode::COMMIT,
122+
}
123+
}
124+
}
113125

114126
impl Entry {
115127
/// Compare one entry to another by their path, by comparing only their common path portion byte by byte, then resorting to

0 commit comments

Comments
 (0)