Skip to content

Commit 3fad860

Browse files
cruesslerByron
authored andcommitted
Make use gix_traverse::commit::Either::tree_id()
This removes a local implementation of it.
1 parent 625f9dd commit 3fad860

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

gix-blame/src/file/function.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,12 @@ fn tree_diff_at_file_path(
452452
lhs_tree_buf: &mut Vec<u8>,
453453
rhs_tree_buf: &mut Vec<u8>,
454454
) -> Result<Option<gix_diff::tree::recorder::Change>, Error> {
455-
let parent_tree_id = tree_id(find_commit(cache, &odb, &parent_id, commit_buf)?)?;
455+
let parent_tree_id = find_commit(cache, &odb, &parent_id, commit_buf)?.tree_id()?;
456456

457457
let parent_tree_iter = odb.find_tree_iter(&parent_tree_id, lhs_tree_buf)?;
458458
stats.trees_decoded += 1;
459459

460-
let tree_id = tree_id(find_commit(cache, &odb, &id, commit_buf)?)?;
460+
let tree_id = find_commit(cache, &odb, &id, commit_buf)?.tree_id()?;
461461

462462
let tree_iter = odb.find_tree_iter(&tree_id, rhs_tree_buf)?;
463463
stats.trees_decoded += 1;
@@ -654,7 +654,7 @@ fn find_path_entry_in_commit(
654654
buf2: &mut Vec<u8>,
655655
stats: &mut Statistics,
656656
) -> Result<Option<ObjectId>, Error> {
657-
let tree_id = tree_id(find_commit(cache, odb, commit, buf)?)?;
657+
let tree_id = find_commit(cache, odb, commit, buf)?.tree_id()?;
658658
let tree_iter = odb.find_tree_iter(&tree_id, buf)?;
659659
stats.trees_decoded += 1;
660660

@@ -710,13 +710,6 @@ fn collect_parents(
710710
Ok(parent_ids)
711711
}
712712

713-
fn tree_id(commit: gix_traverse::commit::Either<'_, '_>) -> Result<ObjectId, Error> {
714-
match commit {
715-
gix_traverse::commit::Either::CommitRefIter(mut commit_ref_iter) => Ok(commit_ref_iter.tree_id()?),
716-
gix_traverse::commit::Either::CachedCommit(commit) => Ok(commit.root_tree_id().into()),
717-
}
718-
}
719-
720713
/// Return an iterator over tokens for use in diffing. These are usually lines, but it's important
721714
/// to unify them so the later access shows the right thing.
722715
pub(crate) fn tokens_for_diffing(data: &[u8]) -> impl TokenSource<Token = &[u8]> {

0 commit comments

Comments
 (0)