@@ -2541,18 +2541,14 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
25412541 return hashfile_checksum_valid (g -> data , g -> data_len );
25422542}
25432543
2544- int verify_commit_graph (struct repository * r , struct commit_graph * g , int flags )
2544+ static int verify_one_commit_graph (struct repository * r ,
2545+ struct commit_graph * g ,
2546+ struct progress * progress ,
2547+ uint64_t * seen )
25452548{
25462549 uint32_t i , cur_fanout_pos = 0 ;
25472550 struct object_id prev_oid , cur_oid ;
25482551 int generation_zero = 0 ;
2549- struct progress * progress = NULL ;
2550- int local_error = 0 ;
2551-
2552- if (!g ) {
2553- graph_report ("no commit-graph file loaded" );
2554- return 1 ;
2555- }
25562552
25572553 verify_commit_graph_error = verify_commit_graph_lite (g );
25582554 if (verify_commit_graph_error )
@@ -2603,17 +2599,13 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
26032599 if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH )
26042600 return verify_commit_graph_error ;
26052601
2606- if (flags & COMMIT_GRAPH_WRITE_PROGRESS )
2607- progress = start_progress (_ ("Verifying commits in commit graph" ),
2608- g -> num_commits );
2609-
26102602 for (i = 0 ; i < g -> num_commits ; i ++ ) {
26112603 struct commit * graph_commit , * odb_commit ;
26122604 struct commit_list * graph_parents , * odb_parents ;
26132605 timestamp_t max_generation = 0 ;
26142606 timestamp_t generation ;
26152607
2616- display_progress (progress , i + 1 );
2608+ display_progress (progress , ++ ( * seen ) );
26172609 oidread (& cur_oid , g -> chunk_oid_lookup + g -> hash_len * i );
26182610
26192611 graph_commit = lookup_commit (r , & cur_oid );
@@ -2696,12 +2688,37 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
26962688 graph_commit -> date ,
26972689 odb_commit -> date );
26982690 }
2699- stop_progress (& progress );
27002691
2701- local_error = verify_commit_graph_error ;
2692+ return verify_commit_graph_error ;
2693+ }
2694+
2695+ int verify_commit_graph (struct repository * r , struct commit_graph * g , int flags )
2696+ {
2697+ struct progress * progress = NULL ;
2698+ int local_error = 0 ;
2699+ uint64_t seen = 0 ;
2700+
2701+ if (!g ) {
2702+ graph_report ("no commit-graph file loaded" );
2703+ return 1 ;
2704+ }
2705+
2706+ if (flags & COMMIT_GRAPH_WRITE_PROGRESS ) {
2707+ uint64_t total = g -> num_commits ;
2708+ if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW ))
2709+ total += g -> num_commits_in_base ;
2710+
2711+ progress = start_progress (_ ("Verifying commits in commit graph" ),
2712+ total );
2713+ }
2714+
2715+ for (; g ; g = g -> base_graph ) {
2716+ local_error |= verify_one_commit_graph (r , g , progress , & seen );
2717+ if (flags & COMMIT_GRAPH_VERIFY_SHALLOW )
2718+ break ;
2719+ }
27022720
2703- if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW ) && g -> base_graph )
2704- local_error |= verify_commit_graph (r , g -> base_graph , flags );
2721+ stop_progress (& progress );
27052722
27062723 return local_error ;
27072724}
0 commit comments