X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=transport.c;h=c9c8056f9de69bd378cd271d70363b5560f13e07;hb=c34fe6304c0162c526b74e8639c94d8d026615fd;hp=69dae711037ea7a54d86910932d74ac2b24b57fd;hpb=69d61daec7a7915f6a664f32002fd9403e7f2a34;p=git.git diff --git a/transport.c b/transport.c index 69dae7110..c9c8056f9 100644 --- a/transport.c +++ b/transport.c @@ -1190,14 +1190,20 @@ literal_copy: return xstrdup(url); } -int refs_from_alternate_cb(struct alternate_object_database *e, void *cb) +struct alternate_refs_data { + alternate_ref_fn *fn; + void *data; +}; + +static int refs_from_alternate_cb(struct alternate_object_database *e, + void *data) { char *other; size_t len; struct remote *remote; struct transport *transport; const struct ref *extra; - alternate_ref_fn *ref_fn = cb; + struct alternate_refs_data *cb = data; e->name[-1] = '\0'; other = xstrdup(real_path(e->base)); @@ -1218,8 +1224,16 @@ int refs_from_alternate_cb(struct alternate_object_database *e, void *cb) for (extra = transport_get_remote_refs(transport); extra; extra = extra->next) - ref_fn(extra, NULL); + cb->fn(extra, cb->data); transport_disconnect(transport); free(other); return 0; } + +void for_each_alternate_ref(alternate_ref_fn fn, void *data) +{ + struct alternate_refs_data cb; + cb.fn = fn; + cb.data = data; + foreach_alt_odb(refs_from_alternate_cb, &cb); +}