Skip to content

Commit

Permalink
rename!: Tree::lookup_path() -> Tree::lookup_entry(). (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 20, 2022
1 parent 15a18e4 commit 79c2255
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions git-repository/src/object/tree/mod.rs
Expand Up @@ -31,7 +31,7 @@ impl<'repo> Tree<'repo> {
/// Searching tree entries is currently done in sequence, which allows to the search to be allocation free. It would be possible
/// to re-use a vector and use a binary search instead, which might be able to improve performance over all.
/// However, a benchmark should be created first to have some data and see which trade-off to choose here.
pub fn lookup_path<I, P>(mut self, path: I) -> Result<Option<git_object::tree::Entry>, find::existing::Error>
pub fn lookup_entry<I, P>(mut self, path: I) -> Result<Option<git_object::tree::Entry>, find::existing::Error>
where
I: IntoIterator<Item = P>,
P: PartialEq<BStr>,
Expand Down Expand Up @@ -67,11 +67,11 @@ impl<'repo> Tree<'repo> {
///
/// If any path component contains illformed UTF-8 and thus can't be converted to bytes on platforms which can't do so natively,
/// the returned component will be empty which makes the lookup fail.
pub fn lookup_path_by_path(
pub fn lookup_entry_by_path(
self,
relative_path: impl AsRef<std::path::Path>,
) -> Result<Option<git_object::tree::Entry>, find::existing::Error> {
self.lookup_path(
self.lookup_entry(
relative_path
.as_ref()
.components()
Expand Down
2 changes: 1 addition & 1 deletion git-repository/src/repository/snapshots.rs
Expand Up @@ -42,7 +42,7 @@ impl crate::Repository {
self.head().ok().and_then(|mut head| {
let commit = head.peel_to_commit_in_place().ok()?;
let tree = commit.tree().ok()?;
tree.lookup_path(Some(".mailmap")).ok()?.map(|e| e.oid)
tree.lookup_entry(Some(".mailmap")).ok()?.map(|e| e.oid)
})
});
}
Expand Down
Expand Up @@ -125,7 +125,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
}
let tree = repo.find_object(tree_id)?.into_tree();
let entry =
tree.lookup_path_by_path(git_path::from_bstr(path))?
tree.lookup_entry_by_path(git_path::from_bstr(path))?
.ok_or_else(|| Error::PathNotFound {
path: path.into(),
object: obj.attach(repo).shorten_or_id(),
Expand Down

0 comments on commit 79c2255

Please sign in to comment.