From: Derrick Stolee Date: Fri, 22 Jun 2018 18:39:24 GMT Subject: Re: [PATCH 20/23] midx: use midx in approximate_object_count Message-ID: <466e191e-6e0c-692c-ff8c-b847f3c4823a@gmail.com> In-Reply-To: On 6/9/2018 2:03 PM, Duy Nguyen wrote: > On Thu, Jun 7, 2018 at 4:06 PM Derrick Stolee wrote: >> Signed-off-by: Derrick Stolee >> --- >> packfile.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/packfile.c b/packfile.c >> index 638e113972..059b2aa097 100644 >> --- a/packfile.c >> +++ b/packfile.c >> @@ -819,11 +819,14 @@ unsigned long approximate_object_count(void) >> { >> if (!the_repository->objects->approximate_object_count_valid) { >> unsigned long count; >> + struct midxed_git *m; >> struct packed_git *p; >> >> prepare_packed_git(the_repository); >> count = 0; >> - for (p = the_repository->objects->packed_git; p; p = p->next) { >> + for (m = get_midxed_git(the_repository); m; m = m->next) >> + count += m->num_objects; >> + for (p = get_packed_git(the_repository); p; p = p->next) { > Please don't change this line, it's not related to this patch. Sure. I'll revert that line. > Same > concern applies, if we have already counted objects in midx we should > ignore packs that belong to it or we double count. Since we do not put packfiles into the packed_git list if they are tracked by the midx, we will not double count. > >> if (open_pack_index(p)) >> continue; >> count += p->num_objects; >> -- >> 2.18.0.rc1 >> >