@@ -2,7 +2,6 @@ use std::{io, path::Path, str::FromStr, sync::atomic::AtomicBool};
2
2
3
3
use anyhow:: { anyhow, Context as AnyhowContext , Result } ;
4
4
use bytesize:: ByteSize ;
5
- use git_pack_for_configuration_only:: index:: traverse:: Outcome ;
6
5
use git_repository as git;
7
6
use git_repository:: {
8
7
easy:: object,
@@ -176,9 +175,17 @@ where
176
175
Some ( file_name) if file_name == "multi-pack-index" => {
177
176
let multi_index = git:: odb:: pack:: multi_index:: File :: at ( path) ?;
178
177
let res = multi_index. verify_integrity ( mode, algorithm. into ( ) , cache, thread_limit, progress, should_interrupt) ?;
179
- for stats in res. pack_traverse_outcomes {
180
- output_outcome ( & mut out, output_statistics, & stats) ?;
181
- }
178
+ match output_statistics {
179
+ Some ( OutputFormat :: Human ) => {
180
+ for ( index_name, stats) in multi_index. index_names ( ) . iter ( ) . zip ( res. pack_traverse_outcomes ) {
181
+ writeln ! ( out, "{}" , index_name. display( ) ) . ok ( ) ;
182
+ drop ( print_statistics ( & mut out, & stats) ) ;
183
+ }
184
+ } ,
185
+ #[ cfg( feature = "serde1" ) ]
186
+ Some ( OutputFormat :: Json ) => serde_json:: to_writer_pretty ( out, & multi_index. index_names ( ) . iter ( ) . zip ( res. pack_traverse_outcomes ) . collect :: < Vec < _ > > ( ) ) ?,
187
+ _ => { }
188
+ } ;
182
189
return Ok ( ( ) )
183
190
} ,
184
191
_ => return Err ( anyhow ! (
@@ -190,25 +197,17 @@ where
190
197
ext => return Err ( anyhow ! ( "Unknown extension {:?}, expecting 'idx' or 'pack'" , ext) ) ,
191
198
} ;
192
199
if let Some ( stats) = res. 1 . as_ref ( ) {
193
- output_outcome ( & mut out, output_statistics, stats) ?;
200
+ #[ cfg_attr( not( feature = "serde1" ) , allow( clippy:: single_match) ) ]
201
+ match output_statistics {
202
+ Some ( OutputFormat :: Human ) => drop ( print_statistics ( & mut out, stats) ) ,
203
+ #[ cfg( feature = "serde1" ) ]
204
+ Some ( OutputFormat :: Json ) => serde_json:: to_writer_pretty ( out, stats) ?,
205
+ _ => { }
206
+ } ;
194
207
}
195
208
Ok ( ( ) )
196
209
}
197
210
198
- fn output_outcome < W1 > ( mut out : & mut W1 , output_statistics : Option < OutputFormat > , stats : & Outcome ) -> anyhow:: Result < ( ) >
199
- where
200
- W1 : io:: Write ,
201
- {
202
- #[ cfg_attr( not( feature = "serde1" ) , allow( clippy:: single_match) ) ]
203
- match output_statistics {
204
- Some ( OutputFormat :: Human ) => drop ( print_statistics ( & mut out, stats) ) ,
205
- #[ cfg( feature = "serde1" ) ]
206
- Some ( OutputFormat :: Json ) => serde_json:: to_writer_pretty ( out, stats) ?,
207
- _ => { }
208
- } ;
209
- Ok ( ( ) )
210
- }
211
-
212
211
fn print_statistics ( out : & mut impl io:: Write , stats : & index:: traverse:: Outcome ) -> io:: Result < ( ) > {
213
212
writeln ! ( out, "objects per delta chain length" ) ?;
214
213
let mut chain_length_to_object: Vec < _ > = stats. objects_per_chain_length . iter ( ) . map ( |( a, b) | ( * a, * b) ) . collect ( ) ;
0 commit comments