@@ -59,12 +59,21 @@ where
59
59
let mut string_heap = BTreeSet :: < & ' static [ u8 ] > :: new ( ) ;
60
60
61
61
let ( commit_authors, stats, is_shallow) = {
62
- let stat_progress = file_stats. then ( || progress. add_child ( "extract stats" ) ) . map ( |mut p| {
62
+ let needs_stats = file_stats || line_stats;
63
+ let stat_progress = needs_stats. then ( || progress. add_child ( "extract stats" ) ) . map ( |mut p| {
63
64
p. init ( None , progress:: count ( "commits" ) ) ;
64
65
p
65
66
} ) ;
66
67
let stat_counter = stat_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
67
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
+ } ) ;
75
+ let change_counter = change_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
76
+
68
77
let mut progress = progress. add_child ( "traverse commit graph" ) ;
69
78
progress. init ( None , progress:: count ( "commits" ) ) ;
70
79
@@ -116,21 +125,22 @@ where
116
125
Ok ( out)
117
126
} ) ;
118
127
119
- let ( tx_tree_id, stat_threads) = ( file_stats || line_stats )
128
+ let ( tx_tree_id, stat_threads) = needs_stats
120
129
. then ( || {
121
130
let num_threads = num_cpus:: get ( ) . saturating_sub ( 1 /*main thread*/ ) . max ( 1 ) ;
122
131
let ( tx, rx) = flume:: unbounded :: < ( u32 , Option < git:: hash:: ObjectId > , git:: hash:: ObjectId ) > ( ) ;
123
132
let stat_workers = ( 0 ..num_threads)
124
133
. map ( |_| {
125
134
scope. spawn ( {
126
- let counter = stat_counter. clone ( ) ;
135
+ let commit_counter = stat_counter. clone ( ) ;
136
+ let change_counter = change_counter. clone ( ) ;
127
137
let mut repo = repo. clone ( ) ;
128
138
repo. object_cache_size_if_unset ( 4 * 1024 * 1024 ) ;
129
139
let rx = rx. clone ( ) ;
130
140
move || -> Result < _ , git:: object:: tree:: diff:: Error > {
131
141
let mut out = Vec :: new ( ) ;
132
142
for ( commit_idx, parent_commit, commit) in rx {
133
- if let Some ( c) = counter . as_ref ( ) {
143
+ if let Some ( c) = commit_counter . as_ref ( ) {
134
144
c. fetch_add ( 1 , Ordering :: SeqCst ) ;
135
145
}
136
146
let mut stat = FileStats :: default ( ) ;
@@ -153,6 +163,9 @@ where
153
163
} ;
154
164
from. changes ( ) . for_each_to_obtain_tree ( & to, |change| {
155
165
use git:: object:: tree:: diff:: change:: Event :: * ;
166
+ if let Some ( c) = change_counter. as_ref ( ) {
167
+ c. fetch_add ( 1 , Ordering :: SeqCst ) ;
168
+ }
156
169
match change. event {
157
170
Addition { entry_mode, .. } => {
158
171
if entry_mode. is_no_tree ( ) {
@@ -232,6 +245,9 @@ where
232
245
}
233
246
None => Vec :: new ( ) ,
234
247
} ;
248
+ if let Some ( mut progress) = change_progress {
249
+ progress. show_throughput ( start) ;
250
+ }
235
251
236
252
Ok ( (
237
253
commit_thread. join ( ) . expect ( "no panic" ) ?,
0 commit comments