summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-03-15 17:31:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-15 19:01:08 (GMT)
commit5b872fff187037829fdd3e494acdf4299ff6e80b (patch)
tree4643765ecf11d956dbafafd51ee40c02336c3ea4 /transport.c
parent230d7dd3917b80d94bf8d522b220d587634f1885 (diff)
downloadgit-5b872fff187037829fdd3e494acdf4299ff6e80b.zip
git-5b872fff187037829fdd3e494acdf4299ff6e80b.tar.gz
git-5b872fff187037829fdd3e494acdf4299ff6e80b.tar.bz2
push: pass ref prefixes when pushing
Construct a list of ref prefixes to be passed to 'get_refs_list()' from the refspec to be used during the push. This list of ref prefixes will be used to allow the server to filter the ref advertisement when communicating using protocol v2. 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.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/transport.c b/transport.c
index 3f13051..57bdbb5 100644
--- a/transport.c
+++ b/transport.c
@@ -1028,11 +1028,38 @@ int transport_push(struct transport *transport,
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
int push_ret, ret, err;
+ struct refspec *tmp_rs;
+ struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
+ int i;
if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
return -1;
- remote_refs = transport->vtable->get_refs_list(transport, 1, NULL);
+ tmp_rs = parse_push_refspec(refspec_nr, refspec);
+ for (i = 0; i < refspec_nr; i++) {
+ const char *prefix = NULL;
+
+ if (tmp_rs[i].dst)
+ prefix = tmp_rs[i].dst;
+ else if (tmp_rs[i].src && !tmp_rs[i].exact_sha1)
+ prefix = tmp_rs[i].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);
+ }
+ }
+
+ remote_refs = transport->vtable->get_refs_list(transport, 1,
+ &ref_prefixes);
+
+ argv_array_clear(&ref_prefixes);
+ free_refspec(refspec_nr, tmp_rs);
if (flags & TRANSPORT_PUSH_ALL)
match_flags |= MATCH_REFS_ALL;