@@ -570,15 +570,7 @@ fn process_change(
570
570
571
571
* offset_in_destination -= number_of_lines_deleted;
572
572
573
- let line_range_in_next_destination =
574
- LineRange :: with_offset ( hunk. range_in_destination . clone ( ) , * offset_in_destination) ;
575
-
576
- new_hunks_to_blame. push ( UnblamedHunk :: from_destination (
577
- line_range_in_next_destination. into ( ) ,
578
- hunk. offset ( ) + * offset_in_destination,
579
- ) ) ;
580
-
581
- ( None , None )
573
+ ( Some ( hunk) , None )
582
574
} else if line_number_in_destination < hunk. range_in_destination . end {
583
575
// <-----> (hunk)
584
576
// | (line_number_in_destination)
@@ -1582,6 +1574,36 @@ fn process_change_works_no_overlap_5() {
1582
1574
assert_eq ! ( offset_in_destination, Offset :: Added ( 1 ) ) ;
1583
1575
}
1584
1576
1577
+ #[ test]
1578
+ fn process_change_works_no_overlap_6 ( ) {
1579
+ let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
1580
+ let mut new_hunks_to_blame: Vec < UnblamedHunk > = vec ! [ ] ;
1581
+ let mut offset_in_destination: Offset = Offset :: Added ( 0 ) ;
1582
+ let suspect = ObjectId :: null ( gix_hash:: Kind :: Sha1 ) ;
1583
+
1584
+ let ( hunk, change) = process_change (
1585
+ & mut lines_blamed,
1586
+ & mut new_hunks_to_blame,
1587
+ & mut offset_in_destination,
1588
+ suspect,
1589
+ // range_in_destination: 22..24
1590
+ Some ( UnblamedHunk :: new ( 23 ..25 , Offset :: Added ( 1 ) ) ) ,
1591
+ Some ( Change :: Deleted ( 20 , 1 ) ) ,
1592
+ ) ;
1593
+
1594
+ assert_eq ! (
1595
+ hunk,
1596
+ Some ( UnblamedHunk {
1597
+ range_in_blamed_file: 23 ..25 ,
1598
+ range_in_destination: 22 ..24
1599
+ } )
1600
+ ) ;
1601
+ assert_eq ! ( change, None ) ;
1602
+ assert_eq ! ( lines_blamed, vec![ ] ) ;
1603
+ assert_eq ! ( new_hunks_to_blame, vec![ ] ) ;
1604
+ assert_eq ! ( offset_in_destination, Offset :: Deleted ( 1 ) ) ;
1605
+ }
1606
+
1585
1607
#[ test]
1586
1608
fn process_change_works_unchanged_hunk ( ) {
1587
1609
let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
@@ -1729,10 +1751,16 @@ fn process_change_works_deleted_hunk_2() {
1729
1751
Some ( Change :: Deleted ( 0 , 4 ) ) ,
1730
1752
) ;
1731
1753
1732
- assert_eq ! ( hunk, None ) ;
1754
+ assert_eq ! (
1755
+ hunk,
1756
+ Some ( UnblamedHunk {
1757
+ range_in_blamed_file: 2 ..16 ,
1758
+ range_in_destination: 2 ..16
1759
+ } )
1760
+ ) ;
1733
1761
assert_eq ! ( change, None ) ;
1734
1762
assert_eq ! ( lines_blamed, vec![ ] ) ;
1735
- assert_eq ! ( new_hunks_to_blame, vec![ UnblamedHunk :: new ( 2 .. 16 , Offset :: Deleted ( 4 ) ) ] ) ;
1763
+ assert_eq ! ( new_hunks_to_blame, vec![ ] ) ;
1736
1764
assert_eq ! ( offset_in_destination, Offset :: Deleted ( 4 ) ) ;
1737
1765
}
1738
1766
0 commit comments