@@ -202,13 +202,17 @@ struct ref_stats {
202202 size_t others ;
203203};
204204
205- struct object_stats {
205+ struct object_values {
206206 size_t tags ;
207207 size_t commits ;
208208 size_t trees ;
209209 size_t blobs ;
210210};
211211
212+ struct object_stats {
213+ struct object_values type_counts ;
214+ };
215+
212216struct repo_structure {
213217 struct ref_stats refs ;
214218 struct object_stats objects ;
@@ -281,9 +285,9 @@ static inline size_t get_total_reference_count(struct ref_stats *stats)
281285 return stats -> branches + stats -> remotes + stats -> tags + stats -> others ;
282286}
283287
284- static inline size_t get_total_object_count (struct object_stats * stats )
288+ static inline size_t get_total_object_values (struct object_values * values )
285289{
286- return stats -> tags + stats -> commits + stats -> trees + stats -> blobs ;
290+ return values -> tags + values -> commits + values -> trees + values -> blobs ;
287291}
288292
289293static void stats_table_setup_structure (struct stats_table * table ,
@@ -302,14 +306,18 @@ static void stats_table_setup_structure(struct stats_table *table,
302306 stats_table_count_addf (table , refs -> remotes , " * %s" , _ ("Remotes" ));
303307 stats_table_count_addf (table , refs -> others , " * %s" , _ ("Others" ));
304308
305- object_total = get_total_object_count ( objects );
309+ object_total = get_total_object_values ( & objects -> type_counts );
306310 stats_table_addf (table , "" );
307311 stats_table_addf (table , "* %s" , _ ("Reachable objects" ));
308312 stats_table_count_addf (table , object_total , " * %s" , _ ("Count" ));
309- stats_table_count_addf (table , objects -> commits , " * %s" , _ ("Commits" ));
310- stats_table_count_addf (table , objects -> trees , " * %s" , _ ("Trees" ));
311- stats_table_count_addf (table , objects -> blobs , " * %s" , _ ("Blobs" ));
312- stats_table_count_addf (table , objects -> tags , " * %s" , _ ("Tags" ));
313+ stats_table_count_addf (table , objects -> type_counts .commits ,
314+ " * %s" , _ ("Commits" ));
315+ stats_table_count_addf (table , objects -> type_counts .trees ,
316+ " * %s" , _ ("Trees" ));
317+ stats_table_count_addf (table , objects -> type_counts .blobs ,
318+ " * %s" , _ ("Blobs" ));
319+ stats_table_count_addf (table , objects -> type_counts .tags ,
320+ " * %s" , _ ("Tags" ));
313321}
314322
315323static void stats_table_print_structure (const struct stats_table * table )
@@ -389,13 +397,13 @@ static void structure_keyvalue_print(struct repo_structure *stats,
389397 (uintmax_t )stats -> refs .others , value_delim );
390398
391399 printf ("objects.commits.count%c%" PRIuMAX "%c" , key_delim ,
392- (uintmax_t )stats -> objects .commits , value_delim );
400+ (uintmax_t )stats -> objects .type_counts . commits , value_delim );
393401 printf ("objects.trees.count%c%" PRIuMAX "%c" , key_delim ,
394- (uintmax_t )stats -> objects .trees , value_delim );
402+ (uintmax_t )stats -> objects .type_counts . trees , value_delim );
395403 printf ("objects.blobs.count%c%" PRIuMAX "%c" , key_delim ,
396- (uintmax_t )stats -> objects .blobs , value_delim );
404+ (uintmax_t )stats -> objects .type_counts . blobs , value_delim );
397405 printf ("objects.tags.count%c%" PRIuMAX "%c" , key_delim ,
398- (uintmax_t )stats -> objects .tags , value_delim );
406+ (uintmax_t )stats -> objects .type_counts . tags , value_delim );
399407
400408 fflush (stdout );
401409}
@@ -473,22 +481,22 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
473481
474482 switch (type ) {
475483 case OBJ_TAG :
476- stats -> tags += oids -> nr ;
484+ stats -> type_counts . tags += oids -> nr ;
477485 break ;
478486 case OBJ_COMMIT :
479- stats -> commits += oids -> nr ;
487+ stats -> type_counts . commits += oids -> nr ;
480488 break ;
481489 case OBJ_TREE :
482- stats -> trees += oids -> nr ;
490+ stats -> type_counts . trees += oids -> nr ;
483491 break ;
484492 case OBJ_BLOB :
485- stats -> blobs += oids -> nr ;
493+ stats -> type_counts . blobs += oids -> nr ;
486494 break ;
487495 default :
488496 BUG ("invalid object type" );
489497 }
490498
491- object_count = get_total_object_count ( stats );
499+ object_count = get_total_object_values ( & stats -> type_counts );
492500 display_progress (data -> progress , object_count );
493501
494502 return 0 ;
0 commit comments