commit-graph: extract fill_oids_from_all_packs()

The write_commit_graph() method is too complex, so we are extracting helper functions one by one. Extract fill_oids_from_all_packs() that reads all pack-files for commits and fills the oid list in the context. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jun 12, 2019 at 06:29 UTC b2c83060525e69f628fb32836e311978e3899e6e
1 file changed +15 -11
commit-graph.c
+15 -11
@@ -950,6 +950,19 @@ static void fill_oids_from_commit_hex(struct write_commit_graph_context *ctx,
950 strbuf_release(&progress_title);
951 }
952
953 +static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
954 +{
955 + if (ctx->report_progress)
956 + ctx->progress = start_delayed_progress(
957 + _("Finding commits for commit graph among packed objects"),
958 + ctx->approx_nr_objects);
959 + for_each_packed_object(add_packed_commits, ctx,
960 + FOR_EACH_OBJECT_PACK_ORDER);
961 + if (ctx->progress_done < ctx->approx_nr_objects)
962 + display_progress(ctx->progress, ctx->approx_nr_objects);
963 + stop_progress(&ctx->progress);
964 +}
965 +
966 int write_commit_graph(const char *obj_dir,
967 struct string_list *pack_indexes,
968 struct string_list *commit_hex,
@@ -1006,17 +1019,8 @@ int write_commit_graph(const char *obj_dir,
1019 if (commit_hex)
1020 fill_oids_from_commit_hex(ctx, commit_hex);
1021
1009 - if (!pack_indexes && !commit_hex) {
1010 - if (ctx->report_progress)
1011 - ctx->progress = start_delayed_progress(
1012 - _("Finding commits for commit graph among packed objects"),
1013 - ctx->approx_nr_objects);
1014 - for_each_packed_object(add_packed_commits, ctx,
1015 - FOR_EACH_OBJECT_PACK_ORDER);
1016 - if (ctx->progress_done < ctx->approx_nr_objects)
1017 - display_progress(ctx->progress, ctx->approx_nr_objects);
1018 - stop_progress(&ctx->progress);
1019 - }
1022 + if (!pack_indexes && !commit_hex)
1023 + fill_oids_from_all_packs(ctx);
1024
1025 close_reachable(ctx);
1026