File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -824,9 +824,33 @@ pub fn blame_file<E>(
824824 break ;
825825 }
826826
827+ let mut buffer = Vec :: new ( ) ;
828+ let commit_id = odb. find_commit ( & suspect, & mut buffer) . unwrap ( ) . tree ( ) ;
829+ let tree = odb. find_tree ( & commit_id, & mut buffer) . unwrap ( ) ;
830+
831+ let Some ( entry) = tree. bisect_entry ( file_path, false ) else {
832+ continue ;
833+ } ;
834+
827835 if parent_ids. len ( ) == 1 {
828836 let parent_id: ObjectId = * parent_ids. last ( ) . unwrap ( ) ;
829837
838+ let mut buffer = Vec :: new ( ) ;
839+ let parent_commit_id = odb. find_commit ( & parent_id, & mut buffer) . unwrap ( ) . tree ( ) ;
840+ let parent_tree = odb. find_tree ( & parent_commit_id, & mut buffer) . unwrap ( ) ;
841+
842+ if let Some ( parent_entry) = parent_tree. bisect_entry ( file_path, false ) {
843+ if entry. oid == parent_entry. oid {
844+ // The blobs storing the blamed file in `entry` and `parent_entry` are identical
845+ // which is why we can pass blame to the parent without further checks.
846+ hunks_to_blame
847+ . iter_mut ( )
848+ . for_each ( |unblamed_hunk| unblamed_hunk. pass_blame ( suspect, parent_id) ) ;
849+
850+ continue ;
851+ }
852+ }
853+
830854 let changes_for_file_path = get_changes_for_file_path ( & odb, file_path, item. id , parent_id) ;
831855
832856 let [ ref modification] : [ gix_diff:: tree:: recorder:: Change ] = changes_for_file_path[ ..] else {
You can’t perform that action at this time.
0 commit comments