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>
Brandon Williams committed
Mar 15, 2018 at 10:31 UTC
230d7dd3917b80d94bf8d522b220d587634f1885
1 file changed
+18
-1
builtin/fetch.c
+18
-1
@@ -332,11 +332,28 @@ static struct ref *get_ref_map(struct transport *transport,
332
struct ref *rm;
333
struct ref *ref_map = NULL;
334
struct ref **tail = &ref_map;
335
+ struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
336
337
/* opportunistically-updated references: */
338
struct ref *orefs = NULL, **oref_tail = &orefs;
339
339
- const struct ref *remote_refs = transport_get_remote_refs(transport, NULL);
340
+ const struct ref *remote_refs;
341
+
342
+ for (i = 0; i < refspec_count; i++) {
343
+ if (!refspecs[i].exact_sha1) {
344
+ const char *glob = strchr(refspecs[i].src, '*');
345
+ if (glob)
346
+ argv_array_pushf(&ref_prefixes, "%.*s",
347
+ (int)(glob - refspecs[i].src),
348
+ refspecs[i].src);
349
+ else
350
+ expand_ref_prefix(&ref_prefixes, refspecs[i].src);
351
+ }
352
+ }
353
+
354
+ remote_refs = transport_get_remote_refs(transport, &ref_prefixes);
355
+
356
+ argv_array_clear(&ref_prefixes);
357
358
if (refspec_count) {
359
struct refspec *fetch_refspec;