11use super :: { process_changes, Change , UnblamedHunk } ;
2- use crate :: { BlameEntry , Error , Outcome , Statistics } ;
2+ use crate :: { BlameEntry , Error , Options , Outcome , Statistics } ;
33use gix_diff:: blob:: intern:: TokenSource ;
44use gix_diff:: tree:: Visit ;
55use gix_hash:: ObjectId ;
@@ -67,7 +67,7 @@ pub fn file(
6767 cache : Option < gix_commitgraph:: Graph > ,
6868 resource_cache : & mut gix_diff:: blob:: Platform ,
6969 file_path : & BStr ,
70- range : Option < Range < u32 > > ,
70+ options : Options ,
7171) -> Result < Outcome , Error > {
7272 let _span = gix_trace:: coarse!( "gix_blame::file()" , ?file_path, ?suspect) ;
7373
@@ -94,7 +94,7 @@ pub fn file(
9494 return Ok ( Outcome :: default ( ) ) ;
9595 }
9696
97- let range_in_blamed_file = one_based_inclusive_to_zero_based_exclusive_range ( range, num_lines_in_blamed) ?;
97+ let range_in_blamed_file = one_based_inclusive_to_zero_based_exclusive_range ( options . range , num_lines_in_blamed) ?;
9898 let mut hunks_to_blame = vec ! [ UnblamedHunk {
9999 range_in_blamed_file: range_in_blamed_file. clone( ) ,
100100 suspects: [ ( suspect, range_in_blamed_file) ] . into( ) ,
@@ -103,7 +103,7 @@ pub fn file(
103103 let ( mut buf, mut buf2) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
104104 let commit = find_commit ( cache. as_ref ( ) , & odb, & suspect, & mut buf) ?;
105105 let mut queue: gix_revwalk:: PriorityQueue < CommitTime , ObjectId > = gix_revwalk:: PriorityQueue :: new ( ) ;
106- queue. insert ( commit_time ( commit) ?, suspect) ;
106+ queue. insert ( commit_time ( & commit) ?, suspect) ;
107107
108108 let mut out = Vec :: new ( ) ;
109109 let mut diff_state = gix_diff:: tree:: State :: default ( ) ;
@@ -122,7 +122,20 @@ pub fn file(
122122 }
123123
124124 let commit = find_commit ( cache. as_ref ( ) , & odb, & suspect, & mut buf) ?;
125+ let commit_time = commit_time ( & commit) ?;
126+
127+ if let Some ( since) = options. since {
128+ if commit_time < since. seconds {
129+ if unblamed_to_out_is_done ( & mut hunks_to_blame, & mut out, suspect) {
130+ break ' outer;
131+ }
132+
133+ continue ;
134+ }
135+ }
136+
125137 let parent_ids: ParentIds = collect_parents ( commit, & odb, cache. as_ref ( ) , & mut buf2) ?;
138+
126139 if parent_ids. is_empty ( ) {
127140 if queue. is_empty ( ) {
128141 // I’m not entirely sure if this is correct yet. `suspect`, at this point, is the
@@ -647,7 +660,7 @@ fn find_path_entry_in_commit(
647660
648661type CommitTime = i64 ;
649662
650- fn commit_time ( commit : gix_traverse:: commit:: Either < ' _ , ' _ > ) -> Result < CommitTime , gix_object:: decode:: Error > {
663+ fn commit_time ( commit : & gix_traverse:: commit:: Either < ' _ , ' _ > ) -> Result < CommitTime , gix_object:: decode:: Error > {
651664 match commit {
652665 gix_traverse:: commit:: Either :: CommitRefIter ( commit_ref_iter) => {
653666 commit_ref_iter. committer ( ) . map ( |c| c. time . seconds )
0 commit comments