@@ -1286,15 +1286,15 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
12861286static void copy_oids_to_commits (struct write_commit_graph_context * ctx )
12871287{
12881288 uint32_t i ;
1289- struct commit_list * parent ;
12901289
12911290 ctx -> num_extra_edges = 0 ;
12921291 if (ctx -> report_progress )
12931292 ctx -> progress = start_delayed_progress (
12941293 _ ("Finding extra edges in commit graph" ),
12951294 ctx -> oids .nr );
12961295 for (i = 0 ; i < ctx -> oids .nr ; i ++ ) {
1297- int num_parents = 0 ;
1296+ unsigned int num_parents ;
1297+
12981298 display_progress (ctx -> progress , i + 1 );
12991299 if (i > 0 && oideq (& ctx -> oids .list [i - 1 ], & ctx -> oids .list [i ]))
13001300 continue ;
@@ -1308,10 +1308,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
13081308
13091309 parse_commit_no_graph (ctx -> commits .list [ctx -> commits .nr ]);
13101310
1311- for (parent = ctx -> commits .list [ctx -> commits .nr ]-> parents ;
1312- parent ; parent = parent -> next )
1313- num_parents ++ ;
1314-
1311+ num_parents = commit_list_count (ctx -> commits .list [ctx -> commits .nr ]-> parents );
13151312 if (num_parents > 2 )
13161313 ctx -> num_extra_edges += num_parents - 1 ;
13171314
@@ -1623,8 +1620,7 @@ static int commit_compare(const void *_a, const void *_b)
16231620
16241621static void sort_and_scan_merged_commits (struct write_commit_graph_context * ctx )
16251622{
1626- uint32_t i , num_parents ;
1627- struct commit_list * parent ;
1623+ uint32_t i ;
16281624
16291625 if (ctx -> report_progress )
16301626 ctx -> progress = start_delayed_progress (
@@ -1642,10 +1638,9 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
16421638 die (_ ("unexpected duplicate commit id %s" ),
16431639 oid_to_hex (& ctx -> commits .list [i ]-> object .oid ));
16441640 } else {
1645- num_parents = 0 ;
1646- for (parent = ctx -> commits .list [i ]-> parents ; parent ; parent = parent -> next )
1647- num_parents ++ ;
1641+ unsigned int num_parents ;
16481642
1643+ num_parents = commit_list_count (ctx -> commits .list [i ]-> parents );
16491644 if (num_parents > 2 )
16501645 ctx -> num_extra_edges += num_parents - 1 ;
16511646 }
0 commit comments