diff options
Diffstat (limited to 'server-info.c')
-rw-r--r-- | server-info.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/server-info.c b/server-info.c index 9ec744e9f2..70e5a26177 100644 --- a/server-info.c +++ b/server-info.c @@ -151,9 +151,20 @@ static int compare_info(const void *a_, const void *b_) return 1; } +static int init_pack_info_fn(struct packed_git *p, void *data) +{ + int *idx = (int *) data; + if (p->pack_local) { + info[*idx] = xcalloc(1, sizeof(struct pack_info)); + info[*idx]->p = p; + info[*idx]->old_num = -1; + (*idx)++; + } + return 0; +} + static void init_pack_info(const char *infofile, int force) { - struct packed_git *p; int stale; int i = 0; @@ -161,24 +172,12 @@ static void init_pack_info(const char *infofile, int force) objdirlen = strlen(objdir); prepare_packed_git(); - for (p = packed_git; p; p = p->next) { - /* we ignore things on alternate path since they are - * not available to the pullers in general. - */ - if (!p->pack_local) - continue; - i++; - } - num_pack = i; + /* we ignore things on alternate path since they are + * not available to the pullers in general. + */ + num_pack = packed_git_local_count(); info = xcalloc(num_pack, sizeof(struct pack_info *)); - for (i = 0, p = packed_git; p; p = p->next) { - if (!p->pack_local) - continue; - info[i] = xcalloc(1, sizeof(struct pack_info)); - info[i]->p = p; - info[i]->old_num = -1; - i++; - } + foreach_packed_git(init_pack_info_fn, NULL, &i); if (infofile && !force) stale = read_pack_info_file(infofile); |