Skip to content

Commit 995ee88

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd1a521 commit 995ee88

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

packfile.c

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -946,40 +946,6 @@ static void prepare_packed_git_one(struct odb_source *source)
946946
string_list_clear(data.garbage, 0);
947947
}
948948

949-
static void prepare_packed_git(struct repository *r);
950-
/*
951-
* Give a fast, rough count of the number of objects in the repository. This
952-
* ignores loose objects completely. If you have a lot of them, then either
953-
* you should repack because your performance will be awful, or they are
954-
* all unreachable objects about to be pruned, in which case they're not really
955-
* interesting as a measure of repo size in the first place.
956-
*/
957-
unsigned long repo_approximate_object_count(struct repository *r)
958-
{
959-
if (!r->objects->approximate_object_count_valid) {
960-
struct odb_source *source;
961-
unsigned long count = 0;
962-
struct packed_git *p;
963-
964-
prepare_packed_git(r);
965-
966-
for (source = r->objects->sources; source; source = source->next) {
967-
struct multi_pack_index *m = get_multi_pack_index(source);
968-
if (m)
969-
count += m->num_objects;
970-
}
971-
972-
for (p = r->objects->packfiles->packs; p; p = p->next) {
973-
if (open_pack_index(p))
974-
continue;
975-
count += p->num_objects;
976-
}
977-
r->objects->approximate_object_count = count;
978-
r->objects->approximate_object_count_valid = 1;
979-
}
980-
return r->objects->approximate_object_count;
981-
}
982-
983949
DEFINE_LIST_SORT(static, sort_packs, struct packed_git, next);
984950

985951
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)
10981064
return &r->objects->packfiles->mru;
10991065
}
11001066

1067+
/*
1068+
* Give a fast, rough count of the number of objects in the repository. This
1069+
* ignores loose objects completely. If you have a lot of them, then either
1070+
* you should repack because your performance will be awful, or they are
1071+
* all unreachable objects about to be pruned, in which case they're not really
1072+
* interesting as a measure of repo size in the first place.
1073+
*/
1074+
unsigned long repo_approximate_object_count(struct repository *r)
1075+
{
1076+
if (!r->objects->approximate_object_count_valid) {
1077+
struct odb_source *source;
1078+
unsigned long count = 0;
1079+
struct packed_git *p;
1080+
1081+
prepare_packed_git(r);
1082+
1083+
for (source = r->objects->sources; source; source = source->next) {
1084+
struct multi_pack_index *m = get_multi_pack_index(source);
1085+
if (m)
1086+
count += m->num_objects;
1087+
}
1088+
1089+
for (p = r->objects->packfiles->packs; p; p = p->next) {
1090+
if (open_pack_index(p))
1091+
continue;
1092+
count += p->num_objects;
1093+
}
1094+
r->objects->approximate_object_count = count;
1095+
r->objects->approximate_object_count_valid = 1;
1096+
}
1097+
return r->objects->approximate_object_count;
1098+
}
1099+
11011100
unsigned long unpack_object_header_buffer(const unsigned char *buf,
11021101
unsigned long len, enum object_type *type, unsigned long *sizep)
11031102
{

0 commit comments

Comments
 (0)