mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
packfile: reorder functions to avoid function declaration
Reorder functions so that we can avoid a forward declaration of `prepare_packed_git()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
bd1a521de8
commit
995ee88027
67
packfile.c
67
packfile.c
@@ -946,40 +946,6 @@ static void prepare_packed_git_one(struct odb_source *source)
|
||||
string_list_clear(data.garbage, 0);
|
||||
}
|
||||
|
||||
static void prepare_packed_git(struct repository *r);
|
||||
/*
|
||||
* 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
|
||||
* you should repack because your performance will be awful, or they are
|
||||
* all unreachable objects about to be pruned, in which case they're not really
|
||||
* interesting as a measure of repo size in the first place.
|
||||
*/
|
||||
unsigned long repo_approximate_object_count(struct repository *r)
|
||||
{
|
||||
if (!r->objects->approximate_object_count_valid) {
|
||||
struct odb_source *source;
|
||||
unsigned long count = 0;
|
||||
struct packed_git *p;
|
||||
|
||||
prepare_packed_git(r);
|
||||
|
||||
for (source = r->objects->sources; source; source = source->next) {
|
||||
struct multi_pack_index *m = get_multi_pack_index(source);
|
||||
if (m)
|
||||
count += m->num_objects;
|
||||
}
|
||||
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next) {
|
||||
if (open_pack_index(p))
|
||||
continue;
|
||||
count += p->num_objects;
|
||||
}
|
||||
r->objects->approximate_object_count = count;
|
||||
r->objects->approximate_object_count_valid = 1;
|
||||
}
|
||||
return r->objects->approximate_object_count;
|
||||
}
|
||||
|
||||
DEFINE_LIST_SORT(static, sort_packs, struct packed_git, next);
|
||||
|
||||
static int sort_pack(const struct packed_git *a, const struct packed_git *b)
|
||||
@@ -1098,6 +1064,39 @@ struct list_head *get_packed_git_mru(struct repository *r)
|
||||
return &r->objects->packfiles->mru;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
* you should repack because your performance will be awful, or they are
|
||||
* all unreachable objects about to be pruned, in which case they're not really
|
||||
* interesting as a measure of repo size in the first place.
|
||||
*/
|
||||
unsigned long repo_approximate_object_count(struct repository *r)
|
||||
{
|
||||
if (!r->objects->approximate_object_count_valid) {
|
||||
struct odb_source *source;
|
||||
unsigned long count = 0;
|
||||
struct packed_git *p;
|
||||
|
||||
prepare_packed_git(r);
|
||||
|
||||
for (source = r->objects->sources; source; source = source->next) {
|
||||
struct multi_pack_index *m = get_multi_pack_index(source);
|
||||
if (m)
|
||||
count += m->num_objects;
|
||||
}
|
||||
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next) {
|
||||
if (open_pack_index(p))
|
||||
continue;
|
||||
count += p->num_objects;
|
||||
}
|
||||
r->objects->approximate_object_count = count;
|
||||
r->objects->approximate_object_count_valid = 1;
|
||||
}
|
||||
return r->objects->approximate_object_count;
|
||||
}
|
||||
|
||||
unsigned long unpack_object_header_buffer(const unsigned char *buf,
|
||||
unsigned long len, enum object_type *type, unsigned long *sizep)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user