diff options
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/transport-helper.c b/transport-helper.c index a72ed18efb..3f380d87d9 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -11,6 +11,7 @@ #include "sigchain.h" #include "argv-array.h" #include "refs.h" +#include "transport-internal.h" static int debug; @@ -535,7 +536,7 @@ static int fetch_with_import(struct transport *transport, else private = xstrdup(name); if (private) { - if (read_ref(private, posn->old_oid.hash) < 0) + if (read_ref(private, &posn->old_oid) < 0) die("Could not read ref %s", private); free(private); } @@ -603,6 +604,7 @@ static int process_connect_service(struct transport *transport, cmdbuf.buf); exit: + strbuf_release(&cmdbuf); fclose(input); return ret; } @@ -649,7 +651,7 @@ static int fetch(struct transport *transport, if (process_connect(transport, 0)) { do_take_over(transport); - return transport->fetch(transport, nr_heads, to_fetch); + return transport->vtable->fetch(transport, nr_heads, to_fetch); } count = 0; @@ -670,6 +672,11 @@ static int fetch(struct transport *transport, if (data->transport_options.update_shallow) set_helper_option(transport, "update-shallow", "true"); + if (data->transport_options.filter_options.choice) + set_helper_option( + transport, "filter", + data->transport_options.filter_options.filter_spec); + if (data->fetch) return fetch_with_fetch(transport, nr_heads, to_fetch); @@ -794,7 +801,8 @@ static int push_update_refs_status(struct helper_data *data, private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name); if (!private) continue; - update_ref("update by helper", private, ref->new_oid.hash, NULL, 0, 0); + update_ref("update by helper", private, &ref->new_oid, NULL, + 0, 0); free(private); } strbuf_release(&buf); @@ -880,7 +888,8 @@ static int push_refs_with_push(struct transport *transport, struct strbuf cas = STRBUF_INIT; strbuf_addf(&cas, "%s:%s", ref->name, oid_to_hex(&ref->old_oid_expect)); - string_list_append(&cas_options, strbuf_detach(&cas, NULL)); + string_list_append_nodup(&cas_options, + strbuf_detach(&cas, NULL)); } } if (buf.len == 0) { @@ -895,6 +904,7 @@ static int push_refs_with_push(struct transport *transport, strbuf_addch(&buf, '\n'); sendline(data, &buf); strbuf_release(&buf); + string_list_clear(&cas_options, 0); return push_update_refs_status(data, remote_refs, flags); } @@ -926,9 +936,10 @@ static int push_refs_with_export(struct transport *transport, struct object_id oid; private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name); - if (private && !get_sha1(private, oid.hash)) { + if (private && !get_oid(private, &oid)) { strbuf_addf(&buf, "^%s", private); - string_list_append(&revlist_args, strbuf_detach(&buf, NULL)); + string_list_append_nodup(&revlist_args, + strbuf_detach(&buf, NULL)); oidcpy(&ref->old_oid, &oid); } free(private); @@ -940,10 +951,9 @@ static int push_refs_with_export(struct transport *transport, int flag; /* Follow symbolic refs (mainly for HEAD). */ - name = resolve_ref_unsafe( - ref->peer_ref->name, - RESOLVE_REF_READING, - oid.hash, &flag); + name = resolve_ref_unsafe(ref->peer_ref->name, + RESOLVE_REF_READING, + &oid, &flag); if (!name || !(flag & REF_ISSYMREF)) name = ref->peer_ref->name; @@ -986,7 +996,7 @@ static int push_refs(struct transport *transport, if (process_connect(transport, 1)) { do_take_over(transport); - return transport->push_refs(transport, remote_refs, flags); + return transport->vtable->push_refs(transport, remote_refs, flags); } if (!remote_refs) { @@ -1034,7 +1044,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push) if (process_connect(transport, for_push)) { do_take_over(transport); - return transport->get_refs_list(transport, for_push); + return transport->vtable->get_refs_list(transport, for_push); } if (data->push && for_push) @@ -1065,8 +1075,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push) if (eon) { if (has_attribute(eon + 1, "unchanged")) { (*tail)->status |= REF_STATUS_UPTODATE; - if (read_ref((*tail)->name, - (*tail)->old_oid.hash) < 0) + if (read_ref((*tail)->name, &(*tail)->old_oid) < 0) die(_("Could not read ref %s"), (*tail)->name); } @@ -1083,6 +1092,15 @@ static struct ref *get_refs_list(struct transport *transport, int for_push) return ret; } +static struct transport_vtable vtable = { + set_helper_option, + get_refs_list, + fetch, + push_refs, + connect_helper, + release_helper +}; + int transport_helper_init(struct transport *transport, const char *name) { struct helper_data *data = xcalloc(1, sizeof(*data)); @@ -1094,12 +1112,7 @@ int transport_helper_init(struct transport *transport, const char *name) debug = 1; transport->data = data; - transport->set_option = set_helper_option; - transport->get_refs_list = get_refs_list; - transport->fetch = fetch; - transport->push_refs = push_refs; - transport->disconnect = release_helper; - transport->connect = connect_helper; + transport->vtable = &vtable; transport->smart_options = &(data->transport_options); return 0; } |