summaryrefslogtreecommitdiff
path: root/http-backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'http-backend.c')
-rw-r--r--http-backend.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/http-backend.c b/http-backend.c
index d2c0a625ce..cf1f2a4372 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -438,25 +438,29 @@ static void get_head(char *arg)
strbuf_release(&buf);
}
+struct pack_info_data {
+ struct strbuf *buf;
+ size_t objdirlen;
+};
+
+static int append_pack_info_fn(struct packed_git *p, void *data)
+{
+ struct pack_info_data *d = (struct pack_info_data *) data;
+ if (p->pack_local)
+ strbuf_addf(d->buf, "P %s\n", p->pack_name + d->objdirlen + 6);
+ return 0;
+}
+
static void get_info_packs(char *arg)
{
size_t objdirlen = strlen(get_object_directory());
struct strbuf buf = STRBUF_INIT;
- struct packed_git *p;
- size_t cnt = 0;
+ struct pack_info_data d = {&buf, objdirlen};
select_getanyfile();
prepare_packed_git();
- for (p = packed_git; p; p = p->next) {
- if (p->pack_local)
- cnt++;
- }
-
- strbuf_grow(&buf, cnt * 53 + 2);
- for (p = packed_git; p; p = p->next) {
- if (p->pack_local)
- strbuf_addf(&buf, "P %s\n", p->pack_name + objdirlen + 6);
- }
+ strbuf_grow(&buf, packed_git_local_count() * 53 + 2);
+ foreach_packed_git(append_pack_info_fn, NULL, &d);
strbuf_addch(&buf, '\n');
hdr_nocache();