@@ -7,11 +7,9 @@ use std::{
77 path:: PathBuf ,
88} ;
99
10- use gix_diff :: blob :: { Platform , Sink } ;
11- use gix_hash :: { oid , ObjectId } ;
10+ use gix_hash :: ObjectId ;
11+ use gix_object :: bstr :: BStr ;
1212use gix_object:: FindExt ;
13- use gix_ref:: bstr:: BStr ;
14- use gix_traverse:: commit:: Simple ;
1513
1614#[ derive( Clone , Copy , Debug , PartialEq ) ]
1715pub enum Offset {
@@ -247,7 +245,7 @@ impl ChangeRecorder {
247245 }
248246}
249247
250- impl Sink for ChangeRecorder {
248+ impl gix_diff :: blob :: Sink for ChangeRecorder {
251249 type Out = Vec < Change > ;
252250
253251 // “imara-diff will compute a line diff by default”, so each `start` and `end` represents a
@@ -661,13 +659,13 @@ fn coalesce_blame_entries(lines_blamed: Vec<BlameEntry>) -> Vec<BlameEntry> {
661659}
662660
663661// TODO: do not instantiate anything, get everything passed as argument.
664- pub fn blame_file < T : gix_object :: Find + gix_object :: FindHeader > (
665- odb : & T ,
666- traverse : & mut Simple < & T , fn ( & oid ) -> bool > ,
667- resource_cache : & mut Platform ,
662+ pub fn blame_file < E > (
663+ odb : impl gix_object :: Find + gix_object :: FindHeader ,
664+ traverse : impl IntoIterator < Item = Result < gix_traverse :: commit :: Info , E > > ,
665+ resource_cache : & mut gix_diff :: blob :: Platform ,
668666 worktree_path : PathBuf ,
669667 file_path : & BStr ,
670- ) -> Vec < BlameEntry > {
668+ ) -> Result < Vec < BlameEntry > , E > {
671669 // TODO
672670 // At a high level, what we want to do is the following:
673671 //
@@ -700,15 +698,13 @@ pub fn blame_file<T: gix_object::Find + gix_object::FindHeader>(
700698 ) ] ;
701699 let mut out: Vec < BlameEntry > = vec ! [ ] ;
702700
703- loop {
704- let item = traverse . next ( ) . unwrap ( ) . unwrap ( ) ;
701+ for item in traverse {
702+ let item = item? ;
705703 let suspect = item. id ;
706704
707- let iter = traverse. commit_iter ( ) ;
708- let parent_ids = iter. parent_ids ( ) . collect :: < Vec < _ > > ( ) ;
709-
705+ let parent_ids = item. parent_ids ;
710706 if parent_ids. is_empty ( ) {
711- // I’m not entirely sure this is correct yet. `suspect`, at this point, is the `id` of
707+ // I’m not entirely sure if this is correct yet. `suspect`, at this point, is the `id` of
712708 // the last `item` that was yielded by `traverse`, so it makes sense to assign the
713709 // remaining lines to it, even though we don’t explicitly check whether that is true
714710 // here. We could perhaps use `needed_to_obtain` to compare `suspect` against an empty
@@ -831,5 +827,5 @@ pub fn blame_file<T: gix_object::Find + gix_object::FindHeader>(
831827 // order on insertion.
832828 out. sort_by ( |a, b| a. range_in_blamed_file . start . cmp ( & b. range_in_blamed_file . start ) ) ;
833829
834- coalesce_blame_entries ( out)
830+ Ok ( coalesce_blame_entries ( out) )
835831}
0 commit comments