@@ -59,12 +59,21 @@ where
5959 let mut string_heap = BTreeSet :: < & ' static [ u8 ] > :: new ( ) ;
6060
6161 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| {
6364 p. init ( None , progress:: count ( "commits" ) ) ;
6465 p
6566 } ) ;
6667 let stat_counter = stat_progress. as_ref ( ) . and_then ( |p| p. counter ( ) ) ;
6768
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+
6877 let mut progress = progress. add_child ( "traverse commit graph" ) ;
6978 progress. init ( None , progress:: count ( "commits" ) ) ;
7079
@@ -116,21 +125,22 @@ where
116125 Ok ( out)
117126 } ) ;
118127
119- let ( tx_tree_id, stat_threads) = ( file_stats || line_stats )
128+ let ( tx_tree_id, stat_threads) = needs_stats
120129 . then ( || {
121130 let num_threads = num_cpus:: get ( ) . saturating_sub ( 1 /*main thread*/ ) . max ( 1 ) ;
122131 let ( tx, rx) = flume:: unbounded :: < ( u32 , Option < git:: hash:: ObjectId > , git:: hash:: ObjectId ) > ( ) ;
123132 let stat_workers = ( 0 ..num_threads)
124133 . map ( |_| {
125134 scope. spawn ( {
126- let counter = stat_counter. clone ( ) ;
135+ let commit_counter = stat_counter. clone ( ) ;
136+ let change_counter = change_counter. clone ( ) ;
127137 let mut repo = repo. clone ( ) ;
128138 repo. object_cache_size_if_unset ( 4 * 1024 * 1024 ) ;
129139 let rx = rx. clone ( ) ;
130140 move || -> Result < _ , git:: object:: tree:: diff:: Error > {
131141 let mut out = Vec :: new ( ) ;
132142 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 ( ) {
134144 c. fetch_add ( 1 , Ordering :: SeqCst ) ;
135145 }
136146 let mut stat = FileStats :: default ( ) ;
@@ -153,6 +163,9 @@ where
153163 } ;
154164 from. changes ( ) . for_each_to_obtain_tree ( & to, |change| {
155165 use git:: object:: tree:: diff:: change:: Event :: * ;
166+ if let Some ( c) = change_counter. as_ref ( ) {
167+ c. fetch_add ( 1 , Ordering :: SeqCst ) ;
168+ }
156169 match change. event {
157170 Addition { entry_mode, .. } => {
158171 if entry_mode. is_no_tree ( ) {
@@ -232,6 +245,9 @@ where
232245 }
233246 None => Vec :: new ( ) ,
234247 } ;
248+ if let Some ( mut progress) = change_progress {
249+ progress. show_throughput ( start) ;
250+ }
235251
236252 Ok ( (
237253 commit_thread. join ( ) . expect ( "no panic" ) ?,
0 commit comments