@@ -66,14 +66,18 @@ where
66
66
} ) ;
67
67
let stat_counter = stat_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
68
68
69
- let change_progress = needs_stats
70
- . then ( || progress. add_child ( "analyzing changes" ) )
71
- . map ( |mut p| {
72
- p. init ( None , progress:: count ( "files" ) ) ;
73
- p
74
- } ) ;
69
+ let change_progress = needs_stats. then ( || progress. add_child ( "find changes" ) ) . map ( |mut p| {
70
+ p. init ( None , progress:: count ( "modified files" ) ) ;
71
+ p
72
+ } ) ;
75
73
let change_counter = change_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
76
74
75
+ let lines_progress = line_stats. then ( || progress. add_child ( "find changes" ) ) . map ( |mut p| {
76
+ p. init ( None , progress:: count ( "diff lines" ) ) ;
77
+ p
78
+ } ) ;
79
+ let lines_counter = lines_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
80
+
77
81
let mut progress = progress. add_child ( "traverse commit graph" ) ;
78
82
progress. init ( None , progress:: count ( "commits" ) ) ;
79
83
@@ -134,6 +138,7 @@ where
134
138
scope. spawn ( {
135
139
let commit_counter = stat_counter. clone ( ) ;
136
140
let change_counter = change_counter. clone ( ) ;
141
+ let lines_counter = lines_counter. clone ( ) ;
137
142
let mut repo = repo. clone ( ) ;
138
143
repo. object_cache_size_if_unset ( 4 * 1024 * 1024 ) ;
139
144
let rx = rx. clone ( ) ;
@@ -143,6 +148,9 @@ where
143
148
if let Some ( c) = commit_counter. as_ref ( ) {
144
149
c. fetch_add ( 1 , Ordering :: SeqCst ) ;
145
150
}
151
+ if git:: interrupt:: is_triggered ( ) {
152
+ return Ok ( out) ;
153
+ }
146
154
let mut files = FileStats :: default ( ) ;
147
155
let mut lines = LineStats :: default ( ) ;
148
156
let from = match parent_commit {
@@ -173,15 +181,23 @@ where
173
181
files. added += 1
174
182
}
175
183
if let Ok ( blob) = id. object ( ) {
176
- lines. added = blob. data . lines_with_terminator ( ) . count ( ) ;
184
+ let nl = blob. data . lines_with_terminator ( ) . count ( ) ;
185
+ lines. added += nl;
186
+ if let Some ( c) = lines_counter. as_ref ( ) {
187
+ c. fetch_add ( nl, Ordering :: SeqCst ) ;
188
+ }
177
189
}
178
190
}
179
191
Deletion { entry_mode, id } => {
180
192
if entry_mode. is_no_tree ( ) {
181
193
files. removed += 1
182
194
}
183
195
if let Ok ( blob) = id. object ( ) {
184
- lines. removed = blob. data . lines_with_terminator ( ) . count ( ) ;
196
+ let nl = blob. data . lines_with_terminator ( ) . count ( ) ;
197
+ lines. removed += nl;
198
+ if let Some ( c) = lines_counter. as_ref ( ) {
199
+ c. fetch_add ( nl, Ordering :: SeqCst ) ;
200
+ }
185
201
}
186
202
}
187
203
Modification { entry_mode, .. } => {
@@ -191,16 +207,26 @@ where
191
207
if line_stats {
192
208
if let Some ( Ok ( diff) ) = change. event . diff ( ) {
193
209
use git:: diff:: lines:: similar:: ChangeTag :: * ;
210
+ let mut nl = 0 ;
194
211
for change in diff
195
212
. text ( git:: diff:: lines:: Algorithm :: Myers )
196
213
. iter_all_changes ( )
197
214
{
198
215
match change. tag ( ) {
199
- Delete => lines. removed += 1 ,
200
- Insert => lines. added += 1 ,
216
+ Delete => {
217
+ lines. removed += 1 ;
218
+ nl += 1 ;
219
+ }
220
+ Insert => {
221
+ lines. added += 1 ;
222
+ nl += 1
223
+ }
201
224
Equal => { }
202
225
}
203
226
}
227
+ if let Some ( c) = lines_counter. as_ref ( ) {
228
+ c. fetch_add ( nl, Ordering :: SeqCst ) ;
229
+ }
204
230
}
205
231
}
206
232
}
@@ -260,6 +286,9 @@ where
260
286
let mut stats = Vec :: new ( ) ;
261
287
for handle in stat_threads {
262
288
stats. extend ( handle. join ( ) . expect ( "no panic" ) ?) ;
289
+ if git:: interrupt:: is_triggered ( ) {
290
+ bail ! ( "Cancelled by user" ) ;
291
+ }
263
292
}
264
293
stats. sort_by_key ( |t| t. 0 ) ;
265
294
progress. show_throughput ( start) ;
@@ -270,6 +299,9 @@ where
270
299
if let Some ( mut progress) = change_progress {
271
300
progress. show_throughput ( start) ;
272
301
}
302
+ if let Some ( mut progress) = lines_progress {
303
+ progress. show_throughput ( start) ;
304
+ }
273
305
274
306
Ok ( (
275
307
commit_thread. join ( ) . expect ( "no panic" ) ?,
0 commit comments