aboutsummaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-12 09:43:01 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-12 08:38:43 -0700
commit6801ffd37df8420917e1feaf03b5f7c175798bff (patch)
tree07c19a65d1974eed84639ed1b5682aae2491f8c3 /commit-graph.c
parentb259f2175b0ccd5574fc6b06b8ec5cbeaa860610 (diff)
downloadgit-6801ffd37df8420917e1feaf03b5f7c175798bff.tar.xz
odb: introduce generic object counting
Similar to the preceding commit, introduce counting of objects on the object database level, replacing the logic that we have in `repo_approximate_object_count()`. Note that the function knows to cache the object count. It's unclear whether this cache is really required as we shouldn't have that many cases where we count objects repeatedly. But to be on the safe side the caching mechanism is retained, with the only excepting being that we also have to use the passed flags as caching key. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/commit-graph.c b/commit-graph.c
index f8e24145a5..c030003330 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2607,7 +2607,8 @@ int write_commit_graph(struct odb_source *source,
replace = ctx.opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
}
- ctx.approx_nr_objects = repo_approximate_object_count(r);
+ if (odb_count_objects(r->objects, ODB_COUNT_OBJECTS_APPROXIMATE, &ctx.approx_nr_objects) < 0)
+ ctx.approx_nr_objects = 0;
if (ctx.append && g) {
for (i = 0; i < g->num_commits; i++) {