1
1
use super :: { process_changes, Change , UnblamedHunk } ;
2
- use crate :: { BlameEntry , Error , Outcome , Statistics } ;
2
+ use crate :: { BlameEntry , Error , Options , Outcome , Statistics } ;
3
3
use gix_diff:: blob:: intern:: TokenSource ;
4
4
use gix_diff:: tree:: Visit ;
5
5
use gix_hash:: ObjectId ;
@@ -67,7 +67,7 @@ pub fn file(
67
67
cache : Option < gix_commitgraph:: Graph > ,
68
68
resource_cache : & mut gix_diff:: blob:: Platform ,
69
69
file_path : & BStr ,
70
- range : Option < Range < u32 > > ,
70
+ options : Options ,
71
71
) -> Result < Outcome , Error > {
72
72
let _span = gix_trace:: coarse!( "gix_blame::file()" , ?file_path, ?suspect) ;
73
73
@@ -94,7 +94,7 @@ pub fn file(
94
94
return Ok ( Outcome :: default ( ) ) ;
95
95
}
96
96
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) ?;
98
98
let mut hunks_to_blame = vec ! [ UnblamedHunk {
99
99
range_in_blamed_file: range_in_blamed_file. clone( ) ,
100
100
suspects: [ ( suspect, range_in_blamed_file) ] . into( ) ,
@@ -103,7 +103,7 @@ pub fn file(
103
103
let ( mut buf, mut buf2) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
104
104
let commit = find_commit ( cache. as_ref ( ) , & odb, & suspect, & mut buf) ?;
105
105
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) ;
107
107
108
108
let mut out = Vec :: new ( ) ;
109
109
let mut diff_state = gix_diff:: tree:: State :: default ( ) ;
@@ -122,7 +122,20 @@ pub fn file(
122
122
}
123
123
124
124
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
+
125
137
let parent_ids: ParentIds = collect_parents ( commit, & odb, cache. as_ref ( ) , & mut buf2) ?;
138
+
126
139
if parent_ids. is_empty ( ) {
127
140
if queue. is_empty ( ) {
128
141
// 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(
647
660
648
661
type CommitTime = i64 ;
649
662
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 > {
651
664
match commit {
652
665
gix_traverse:: commit:: Either :: CommitRefIter ( commit_ref_iter) => {
653
666
commit_ref_iter. committer ( ) . map ( |c| c. time . seconds )
0 commit comments