summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-03-15 10:31:25 -0700
committerJunio C Hamano <gitster@pobox.com>2018-03-15 12:01:08 -0700
commit230d7dd3917b80d94bf8d522b220d587634f1885 (patch)
tree753ceb74e45b7066c1a01b5bfb2055f6a376149f
parentb4be74105febef5c6235e1e2f1e468e76166cad8 (diff)
downloadgit-230d7dd3917b80d94bf8d522b220d587634f1885.tar.gz
fetch: pass ref prefixes when fetching
Construct a list of ref prefixes to be passed to 'transport_get_remote_refs()' from the refspec to be used during the fetch. 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>
-rw-r--r--builtin/fetch.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 850382f559..8258bbf950 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -332,11 +332,28 @@ static struct ref *get_ref_map(struct transport *transport,
struct ref *rm;
struct ref *ref_map = NULL;
struct ref **tail = &ref_map;
+ struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
/* opportunistically-updated references: */
struct ref *orefs = NULL, **oref_tail = &orefs;
- const struct ref *remote_refs = transport_get_remote_refs(transport, NULL);
+ const struct ref *remote_refs;
+
+ for (i = 0; i < refspec_count; i++) {
+ if (!refspecs[i].exact_sha1) {
+ const char *glob = strchr(refspecs[i].src, '*');
+ if (glob)
+ argv_array_pushf(&ref_prefixes, "%.*s",
+ (int)(glob - refspecs[i].src),
+ refspecs[i].src);
+ else
+ expand_ref_prefix(&ref_prefixes, refspecs[i].src);
+ }
+ }
+
+ remote_refs = transport_get_remote_refs(transport, &ref_prefixes);
+
+ argv_array_clear(&ref_prefixes);
if (refspec_count) {
struct refspec *fetch_refspec;