Skip to content

Commit 93ba186

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: extract fill_oids_from_all_packs()
The write_commit_graph() method is too complex, so we are extracting methods 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 63a8be6 commit 93ba186

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

commit-graph.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,19 @@ static void fill_oids_from_commit_hex(struct write_commit_graph_context *ctx,
950950
strbuf_release(&progress_title);
951951
}
952952

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+
953966
int write_commit_graph(const char *obj_dir,
954967
struct string_list *pack_indexes,
955968
struct string_list *commit_hex,
@@ -1006,17 +1019,8 @@ int write_commit_graph(const char *obj_dir,
10061019
if (commit_hex)
10071020
fill_oids_from_commit_hex(ctx, commit_hex);
10081021

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);
10201024

10211025
close_reachable(ctx);
10221026

0 commit comments

Comments
 (0)