summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2019-06-12 13:29:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-12 18:20:54 (GMT)
commitb2c83060525e69f628fb32836e311978e3899e6e (patch)
tree14a198b5a962759c8c980be123cb87055f484a19 /commit-graph.c
parent4c9efe850d75115a6deedd57072f1d7383bc03da (diff)
downloadgit-b2c83060525e69f628fb32836e311978e3899e6e.zip
git-b2c83060525e69f628fb32836e311978e3899e6e.tar.gz
git-b2c83060525e69f628fb32836e311978e3899e6e.tar.bz2
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>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 4fae1fc..61cb43d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -950,6 +950,19 @@ static void fill_oids_from_commit_hex(struct write_commit_graph_context *ctx,
strbuf_release(&progress_title);
}
+static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
+{
+ if (ctx->report_progress)
+ ctx->progress = start_delayed_progress(
+ _("Finding commits for commit graph among packed objects"),
+ ctx->approx_nr_objects);
+ for_each_packed_object(add_packed_commits, ctx,
+ FOR_EACH_OBJECT_PACK_ORDER);
+ if (ctx->progress_done < ctx->approx_nr_objects)
+ display_progress(ctx->progress, ctx->approx_nr_objects);
+ stop_progress(&ctx->progress);
+}
+
int write_commit_graph(const char *obj_dir,
struct string_list *pack_indexes,
struct string_list *commit_hex,
@@ -1006,17 +1019,8 @@ int write_commit_graph(const char *obj_dir,
if (commit_hex)
fill_oids_from_commit_hex(ctx, commit_hex);
- if (!pack_indexes && !commit_hex) {
- if (ctx->report_progress)
- ctx->progress = start_delayed_progress(
- _("Finding commits for commit graph among packed objects"),
- ctx->approx_nr_objects);
- for_each_packed_object(add_packed_commits, ctx,
- FOR_EACH_OBJECT_PACK_ORDER);
- if (ctx->progress_done < ctx->approx_nr_objects)
- display_progress(ctx->progress, ctx->approx_nr_objects);
- stop_progress(&ctx->progress);
- }
+ if (!pack_indexes && !commit_hex)
+ fill_oids_from_all_packs(ctx);
close_reachable(ctx);