@@ -912,6 +912,44 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
912
912
return 0 ;
913
913
}
914
914
915
+ static void fill_oids_from_commit_hex (struct write_commit_graph_context * ctx ,
916
+ struct string_list * commit_hex )
917
+ {
918
+ uint32_t i ;
919
+ struct strbuf progress_title = STRBUF_INIT ;
920
+
921
+ if (ctx -> report_progress ) {
922
+ strbuf_addf (& progress_title ,
923
+ Q_ ("Finding commits for commit graph from %d ref" ,
924
+ "Finding commits for commit graph from %d refs" ,
925
+ commit_hex -> nr ),
926
+ commit_hex -> nr );
927
+ ctx -> progress = start_delayed_progress (
928
+ progress_title .buf ,
929
+ commit_hex -> nr );
930
+ }
931
+ for (i = 0 ; i < commit_hex -> nr ; i ++ ) {
932
+ const char * end ;
933
+ struct object_id oid ;
934
+ struct commit * result ;
935
+
936
+ display_progress (ctx -> progress , i + 1 );
937
+ if (commit_hex -> items [i ].string &&
938
+ parse_oid_hex (commit_hex -> items [i ].string , & oid , & end ))
939
+ continue ;
940
+
941
+ result = lookup_commit_reference_gently (ctx -> r , & oid , 1 );
942
+
943
+ if (result ) {
944
+ ALLOC_GROW (ctx -> oids .list , ctx -> oids .nr + 1 , ctx -> oids .alloc );
945
+ oidcpy (& ctx -> oids .list [ctx -> oids .nr ], & (result -> object .oid ));
946
+ ctx -> oids .nr ++ ;
947
+ }
948
+ }
949
+ stop_progress (& ctx -> progress );
950
+ strbuf_release (& progress_title );
951
+ }
952
+
915
953
int write_commit_graph (const char * obj_dir ,
916
954
struct string_list * pack_indexes ,
917
955
struct string_list * commit_hex ,
@@ -965,38 +1003,8 @@ int write_commit_graph(const char *obj_dir,
965
1003
goto cleanup ;
966
1004
}
967
1005
968
- if (commit_hex ) {
969
- if (ctx -> report_progress ) {
970
- strbuf_addf (& progress_title ,
971
- Q_ ("Finding commits for commit graph from %d ref" ,
972
- "Finding commits for commit graph from %d refs" ,
973
- commit_hex -> nr ),
974
- commit_hex -> nr );
975
- ctx -> progress = start_delayed_progress (
976
- progress_title .buf ,
977
- commit_hex -> nr );
978
- }
979
- for (i = 0 ; i < commit_hex -> nr ; i ++ ) {
980
- const char * end ;
981
- struct object_id oid ;
982
- struct commit * result ;
983
-
984
- display_progress (ctx -> progress , i + 1 );
985
- if (commit_hex -> items [i ].string &&
986
- parse_oid_hex (commit_hex -> items [i ].string , & oid , & end ))
987
- continue ;
988
-
989
- result = lookup_commit_reference_gently (ctx -> r , & oid , 1 );
990
-
991
- if (result ) {
992
- ALLOC_GROW (ctx -> oids .list , ctx -> oids .nr + 1 , ctx -> oids .alloc );
993
- oidcpy (& ctx -> oids .list [ctx -> oids .nr ], & (result -> object .oid ));
994
- ctx -> oids .nr ++ ;
995
- }
996
- }
997
- stop_progress (& ctx -> progress );
998
- strbuf_reset (& progress_title );
999
- }
1006
+ if (commit_hex )
1007
+ fill_oids_from_commit_hex (ctx , commit_hex );
1000
1008
1001
1009
if (!pack_indexes && !commit_hex ) {
1002
1010
if (ctx -> report_progress )
0 commit comments