@@ -1838,16 +1838,6 @@ fn get_mtime(cache: &mut HashMap<PathBuf, u128>, file_path: &PathBuf) -> u128 {
1838
1838
}
1839
1839
}
1840
1840
1841
- fn diff_hash ( diff : & str ) -> String {
1842
- let addition = diff
1843
- . lines ( )
1844
- . skip ( 1 ) // skip the first line which is the diff header
1845
- . filter ( |line| line. starts_with ( '+' ) || line. starts_with ( '-' ) ) // exclude context lines
1846
- . collect :: < Vec < _ > > ( )
1847
- . join ( "\n " ) ;
1848
- format ! ( "{:x}" , md5:: compute( addition) )
1849
- }
1850
-
1851
1841
pub fn virtual_hunks_by_filepath (
1852
1842
project_path : & Path ,
1853
1843
diff : & HashMap < PathBuf , Vec < diff:: GitHunk > > ,
@@ -1866,7 +1856,7 @@ pub fn virtual_hunks_by_filepath(
1866
1856
start : hunk. new_start ,
1867
1857
end : hunk. new_start + hunk. new_lines ,
1868
1858
binary : hunk. binary ,
1869
- hash : diff_hash ( & hunk. diff ) ,
1859
+ hash : Hunk :: hash ( & hunk. diff ) ,
1870
1860
locked : false ,
1871
1861
locked_to : None ,
1872
1862
change_type : hunk. change_type ,
@@ -2052,7 +2042,7 @@ fn get_applied_status(
2052
2042
. filter_map ( |claimed_hunk| {
2053
2043
// if any of the current hunks intersects with the owned hunk, we want to keep it
2054
2044
for ( i, git_diff_hunk) in git_diff_hunks. iter ( ) . enumerate ( ) {
2055
- let hash = diff_hash ( & git_diff_hunk. diff ) ;
2045
+ let hash = Hunk :: hash ( & git_diff_hunk. diff ) ;
2056
2046
// Eq compares hashes first, and if one of the hunks lacks a hash, it compares line numbers
2057
2047
if claimed_hunk. eq ( & Hunk :: from ( git_diff_hunk) ) {
2058
2048
// try to re-use old timestamp
@@ -2132,7 +2122,7 @@ fn get_applied_status(
2132
2122
file_path : filepath. clone ( ) ,
2133
2123
hunks : vec ! [ Hunk :: from( & hunk)
2134
2124
. with_timestamp( get_mtime( & mut mtimes, & filepath) )
2135
- . with_hash( diff_hash ( hunk. diff. as_str( ) ) . as_str( ) ) ] ,
2125
+ . with_hash( Hunk :: hash ( hunk. diff. as_str( ) ) . as_str( ) ) ] ,
2136
2126
} ) ;
2137
2127
diffs_by_branch
2138
2128
. entry ( virtual_branches[ default_vbranch_pos] . id )
0 commit comments