@@ -457,9 +457,21 @@ fn process_change(
457457 ) ) ;
458458 }
459459
460- lines_blamed. push ( BlameEntry :: new ( added. start ..hunk. range_in_destination . end , suspect) ) ;
460+ lines_blamed. push ( BlameEntry :: with_offset (
461+ added. start ..hunk. range_in_destination . end ,
462+ suspect,
463+ hunk. offset ( ) ,
464+ ) ) ;
461465
462- ( None , None )
466+ let new_change = if added. end > hunk. range_in_destination . end {
467+ let line_range = hunk. range_in_destination . end ..added. end ;
468+
469+ Some ( Change :: Added ( line_range, number_of_lines_deleted) )
470+ } else {
471+ todo ! ( ) ;
472+ } ;
473+
474+ ( None , new_change)
463475 }
464476 ( false , true ) => {
465477 * offset_in_destination += added. end - added. start ;
@@ -1227,6 +1239,36 @@ fn process_change_works_added_hunk_7() {
12271239 assert_eq ! ( offset_in_destination, Offset :: Added ( 3 ) ) ;
12281240}
12291241
1242+ #[ test]
1243+ fn process_change_works_added_hunk_8 ( ) {
1244+ let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
1245+ let mut new_hunks_to_blame: Vec < UnblamedHunk > = vec ! [ ] ;
1246+ let mut offset_in_destination: Offset = Offset :: Added ( 1 ) ;
1247+ let suspect = ObjectId :: null ( gix_hash:: Kind :: Sha1 ) ;
1248+
1249+ let ( hunk, change) = process_change (
1250+ & mut lines_blamed,
1251+ & mut new_hunks_to_blame,
1252+ & mut offset_in_destination,
1253+ suspect,
1254+ // range_in_destination: 25..26
1255+ Some ( UnblamedHunk :: new ( 23 ..24 , Offset :: Deleted ( 2 ) ) ) ,
1256+ Some ( Change :: Added ( 25 ..27 , 1 ) ) ,
1257+ ) ;
1258+
1259+ assert_eq ! ( hunk, None ) ;
1260+ assert_eq ! ( change, Some ( Change :: Added ( 26 ..27 , 1 ) ) ) ;
1261+ assert_eq ! (
1262+ lines_blamed,
1263+ vec![ BlameEntry {
1264+ range: 23 ..24 ,
1265+ commit_id: suspect
1266+ } ]
1267+ ) ;
1268+ assert_eq ! ( new_hunks_to_blame, vec![ ] ) ;
1269+ assert_eq ! ( offset_in_destination, Offset :: Added ( 2 ) ) ;
1270+ }
1271+
12301272#[ test]
12311273fn process_change_works_no_overlap ( ) {
12321274 let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
0 commit comments