diff options
author | Eric Wong <e@80x24.org> | 2019-05-23 19:27:23 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-05-28 20:02:52 +0200 |
commit | e941c48d49ebe24404515acf258d8003f2374627 (patch) | |
tree | a4c1552889d97511831b791517b0d9d3d56d5ddd /server-info.c | |
parent | Git 2.22-rc1 (diff) | |
download | git-e941c48d49ebe24404515acf258d8003f2374627.tar.xz git-e941c48d49ebe24404515acf258d8003f2374627.zip |
server-info: do not list unlinked packs
Having non-existent packs in objects/info/packs causes
dumb HTTP clients to abort.
v2: use single loop with ALLOC_GROW as suggested by Jeff King
Signed-off-by: Eric Wong <e@80x24.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'server-info.c')
-rw-r--r-- | server-info.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/server-info.c b/server-info.c index 41274d098b..92187c70db 100644 --- a/server-info.c +++ b/server-info.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "dir.h" #include "repository.h" #include "refs.h" #include "object.h" @@ -191,26 +192,21 @@ static void init_pack_info(const char *infofile, int force) { struct packed_git *p; int stale; - int i = 0; + int i; + size_t alloc = 0; for (p = get_all_packs(the_repository); 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; - info = xcalloc(num_pack, sizeof(struct pack_info *)); - for (i = 0, p = get_all_packs(the_repository); p; p = p->next) { - if (!p->pack_local) + if (!p->pack_local || !file_exists(p->pack_name)) continue; - assert(i < num_pack); + + i = num_pack++; + ALLOC_GROW(info, num_pack, alloc); info[i] = xcalloc(1, sizeof(struct pack_info)); info[i]->p = p; info[i]->old_num = -1; - i++; } if (infofile && !force) |