diff options
author | Brandon Williams <bmwill@google.com> | 2018-05-17 01:48:21 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-17 23:35:35 +0200 |
commit | 6373cb598e1a4e0340583ad75d5abba01ff79774 (patch) | |
tree | d9d49fbbc92bebbd228816ca736af7b23403c74f /transport.c | |
parent | submodule: convert push_unpushed_submodules to take a struct refspec (diff) | |
download | git-6373cb598e1a4e0340583ad75d5abba01ff79774.tar.xz git-6373cb598e1a4e0340583ad75d5abba01ff79774.zip |
refspec: consolidate ref-prefix generation logic
When using protocol v2 a client constructs a list of ref-prefixes which
are sent across the wire so that the server can do server-side filtering
of the ref-advertisement. The logic that does this exists for both
fetch and push (even though no push support for v2 currently exists yet)
and is roughly the same so lets consolidate this logic and make it
general enough that it can be used for both the push and fetch cases.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/transport.c b/transport.c index 7e0b9abba3..cbf0044c3e 100644 --- a/transport.c +++ b/transport.c @@ -1088,30 +1088,11 @@ int transport_push(struct transport *transport, int pretend = flags & TRANSPORT_PUSH_DRY_RUN; int push_ret, ret, err; struct argv_array ref_prefixes = ARGV_ARRAY_INIT; - int i; if (check_push_refs(local_refs, rs) < 0) return -1; - for (i = 0; i < rs->nr; i++) { - const struct refspec_item *item = &rs->items[i]; - const char *prefix = NULL; - - if (item->dst) - prefix = item->dst; - else if (item->src && !item->exact_sha1) - prefix = item->src; - - if (prefix) { - const char *glob = strchr(prefix, '*'); - if (glob) - argv_array_pushf(&ref_prefixes, "%.*s", - (int)(glob - prefix), - prefix); - else - expand_ref_prefix(&ref_prefixes, prefix); - } - } + refspec_ref_prefixes(rs, &ref_prefixes); remote_refs = transport->vtable->get_refs_list(transport, 1, &ref_prefixes); |