From 596184786c1b1998573df4c130eadb1668d8c304 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 12 May 2025 14:51:30 -0400 Subject: oidmap: add size function Callers which want to know how many items are in an oidmap have to look at the underlying hashmap struct, leaking an implementation detail. Let's provide a type-appropriate wrapper and use it. Note in the call from lookup_replace_object(), the caller was actually looking at the hashmap's tablesize parameter (the allocated size of the table) rather than hashmap_get_size(), the number of items in the table. This probably should have been checking the number of items all along, but the two are functionally equivalent here since we only add to the map and never remove anything. Thus if there was any allocation, it was because there is at least one item. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- commit-graph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'commit-graph.c') diff --git a/commit-graph.c b/commit-graph.c index 6394752b0b..1a74e1e1ba 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -222,7 +222,7 @@ static int commit_graph_compatible(struct repository *r) if (replace_refs_enabled(r)) { prepare_replace_object(r); - if (hashmap_get_size(&r->objects->replace_map->map)) + if (oidmap_get_size(r->objects->replace_map)) return 0; } -- cgit v1.2.3