@@ -984,6 +984,37 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
984
984
return count_distinct ;
985
985
}
986
986
987
+ static void copy_oids_to_commits (struct write_commit_graph_context * ctx )
988
+ {
989
+ uint32_t i ;
990
+ struct commit_list * parent ;
991
+
992
+ ctx -> num_extra_edges = 0 ;
993
+ if (ctx -> report_progress )
994
+ ctx -> progress = start_delayed_progress (
995
+ _ ("Finding extra edges in commit graph" ),
996
+ ctx -> oids .nr );
997
+ for (i = 0 ; i < ctx -> oids .nr ; i ++ ) {
998
+ int num_parents = 0 ;
999
+ display_progress (ctx -> progress , i + 1 );
1000
+ if (i > 0 && oideq (& ctx -> oids .list [i - 1 ], & ctx -> oids .list [i ]))
1001
+ continue ;
1002
+
1003
+ ctx -> commits .list [ctx -> commits .nr ] = lookup_commit (ctx -> r , & ctx -> oids .list [i ]);
1004
+ parse_commit_no_graph (ctx -> commits .list [ctx -> commits .nr ]);
1005
+
1006
+ for (parent = ctx -> commits .list [ctx -> commits .nr ]-> parents ;
1007
+ parent ; parent = parent -> next )
1008
+ num_parents ++ ;
1009
+
1010
+ if (num_parents > 2 )
1011
+ ctx -> num_extra_edges += num_parents - 1 ;
1012
+
1013
+ ctx -> commits .nr ++ ;
1014
+ }
1015
+ stop_progress (& ctx -> progress );
1016
+ }
1017
+
987
1018
int write_commit_graph (const char * obj_dir ,
988
1019
struct string_list * pack_indexes ,
989
1020
struct string_list * commit_hex ,
@@ -997,7 +1028,6 @@ int write_commit_graph(const char *obj_dir,
997
1028
uint32_t chunk_ids [5 ];
998
1029
uint64_t chunk_offsets [5 ];
999
1030
int num_chunks ;
1000
- struct commit_list * parent ;
1001
1031
const unsigned hashsz = the_hash_algo -> rawsz ;
1002
1032
struct strbuf progress_title = STRBUF_INIT ;
1003
1033
int res = 0 ;
@@ -1056,30 +1086,7 @@ int write_commit_graph(const char *obj_dir,
1056
1086
ctx -> commits .alloc = count_distinct ;
1057
1087
ALLOC_ARRAY (ctx -> commits .list , ctx -> commits .alloc );
1058
1088
1059
- ctx -> num_extra_edges = 0 ;
1060
- if (ctx -> report_progress )
1061
- ctx -> progress = start_delayed_progress (
1062
- _ ("Finding extra edges in commit graph" ),
1063
- ctx -> oids .nr );
1064
- for (i = 0 ; i < ctx -> oids .nr ; i ++ ) {
1065
- int num_parents = 0 ;
1066
- display_progress (ctx -> progress , i + 1 );
1067
- if (i > 0 && oideq (& ctx -> oids .list [i - 1 ], & ctx -> oids .list [i ]))
1068
- continue ;
1069
-
1070
- ctx -> commits .list [ctx -> commits .nr ] = lookup_commit (ctx -> r , & ctx -> oids .list [i ]);
1071
- parse_commit_no_graph (ctx -> commits .list [ctx -> commits .nr ]);
1072
-
1073
- for (parent = ctx -> commits .list [ctx -> commits .nr ]-> parents ;
1074
- parent ; parent = parent -> next )
1075
- num_parents ++ ;
1076
-
1077
- if (num_parents > 2 )
1078
- ctx -> num_extra_edges += num_parents - 1 ;
1079
-
1080
- ctx -> commits .nr ++ ;
1081
- }
1082
- stop_progress (& ctx -> progress );
1089
+ copy_oids_to_commits (ctx );
1083
1090
1084
1091
if (ctx -> commits .nr >= GRAPH_EDGE_LAST_MASK ) {
1085
1092
error (_ ("too many commits to write graph" ));
0 commit comments