Skip to content

Commit

Permalink
Implement Tree::get_name using Tree::get_name_bytes to avoid dupl…
Browse files Browse the repository at this point in the history
…ication
  • Loading branch information
joshtriplett committed May 10, 2022
1 parent 23a5340 commit 6316180
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,7 @@ impl<'repo> Tree<'repo> {

/// Lookup a tree entry by its filename
pub fn get_name(&self, filename: &str) -> Option<TreeEntry<'_>> {
let filename = CString::new(filename).unwrap();
unsafe {
let ptr = call!(raw::git_tree_entry_byname(&*self.raw(), filename));
if ptr.is_null() {
None
} else {
Some(entry_from_raw_const(ptr))
}
}
self.get_name_bytes(filename.as_bytes())
}

/// Lookup a tree entry by its filename, specified as bytes.
Expand Down

0 comments on commit 6316180

Please sign in to comment.