/* A most-recently-used ordered version of the packed_git list. */
struct list_head packed_git_mru;
+ /*
+ * A fast, rough count of the number of objects in the repository.
+ * These two fields are not meant for direct access. Use
+ * approximate_object_count() instead.
+ */
+ unsigned long approximate_object_count;
+ unsigned approximate_object_count_valid : 1;
+
/*
* Whether packed_git has already been populated with this repository's
* packs.
strbuf_release(&path);
}
-static int approximate_object_count_valid;
-
/*
* Give a fast, rough count of the number of objects in the repository. This
* ignores loose objects completely. If you have a lot of them, then either
*/
unsigned long approximate_object_count(void)
{
- static unsigned long count;
- if (!approximate_object_count_valid) {
+ if (!the_repository->objects->approximate_object_count_valid) {
+ unsigned long count;
struct packed_git *p;
prepare_packed_git();
continue;
count += p->num_objects;
}
+ the_repository->objects->approximate_object_count = count;
}
- return count;
+ return the_repository->objects->approximate_object_count;
}
static void *get_next_packed_git(const void *p)
void reprepare_packed_git(void)
{
- approximate_object_count_valid = 0;
+ the_repository->objects->approximate_object_count_valid = 0;
the_repository->objects->packed_git_initialized = 0;
prepare_packed_git();
}