Skip to content

Commit 9f26645

Browse files
committed
feat: add conversion from tree::Entry to EntryRef with From
1 parent 0963abe commit 9f26645

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

gix-object/src/object/convert.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ impl From<tree::EntryRef<'_>> for tree::Entry {
7878
}
7979
}
8080

81+
impl<'a> From<&'a tree::Entry> for tree::EntryRef<'a> {
82+
fn from(other: &'a tree::Entry) -> tree::EntryRef<'a> {
83+
let tree::Entry { mode, filename, oid } = other;
84+
tree::EntryRef {
85+
mode: *mode,
86+
filename: filename.as_ref(),
87+
oid,
88+
}
89+
}
90+
}
91+
8192
impl From<ObjectRef<'_>> for Object {
8293
fn from(v: ObjectRef<'_>) -> Self {
8394
match v {

gix-object/tests/object/tree/editor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ fn from_existing_add() -> crate::Result {
619619
let root_tree = find_tree(&odb, root_tree_id)?;
620620
odb.access_count_and_clear();
621621
let mut edit = gix_object::tree::Editor::new(root_tree.clone(), &odb, gix_hash::Kind::Sha1);
622+
assert!(edit.get(["bin"]).is_some(), "the root is immediately available");
622623

623624
let actual = edit.write(&mut write).expect("no changes are fine");
624625
assert_eq!(actual, root_tree_id, "it rewrites the same tree");

0 commit comments

Comments
 (0)