diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-29 23:51:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-29 23:51:22 -0700 |
commit | 01f9ffbd5d3f480c9a524780d86fa0d4134841af (patch) | |
tree | 40a47451f2a72180a1497fca3ac157ff1f114226 /transport.c | |
parent | plug a DIR buffer leak in rerere.c (diff) | |
parent | receive-pack: eliminate duplicate .have refs (diff) | |
download | tgif-01f9ffbd5d3f480c9a524780d86fa0d4134841af.tar.xz |
Merge branch 'jk/haves-from-alternate-odb'
* jk/haves-from-alternate-odb:
receive-pack: eliminate duplicate .have refs
bisect: refactor sha1_array into a generic sha1 list
refactor refs_from_alternate_cb to allow passing extra data
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/transport.c b/transport.c index a02f79aae3..1a3998ee51 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); +} |