From b4be74105febef5c6235e1e2f1e468e76166cad8 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 15 Mar 2018 10:31:24 -0700 Subject: ls-remote: pass ref prefixes when requesting a remote's refs Construct an argv_array of ref prefixes based on the patterns supplied via the command line and pass them to 'transport_get_remote_refs()' to be used when communicating protocol v2 so that the server can limit the ref advertisement based on those prefixes. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- refs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'refs.c') diff --git a/refs.c b/refs.c index 20ba82b434..cefbad2076 100644 --- a/refs.c +++ b/refs.c @@ -13,6 +13,7 @@ #include "tag.h" #include "submodule.h" #include "worktree.h" +#include "argv-array.h" /* * List of all available backends @@ -501,6 +502,19 @@ int refname_match(const char *abbrev_name, const char *full_name) return 0; } +/* + * Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add + * the results to 'prefixes' + */ +void expand_ref_prefix(struct argv_array *prefixes, const char *prefix) +{ + const char **p; + int len = strlen(prefix); + + for (p = ref_rev_parse_rules; *p; p++) + argv_array_pushf(prefixes, *p, len, prefix); +} + /* * *string and *len will only be substituted, and *string returned (for * later free()ing) if the string passed in is a magic short-hand form -- cgit v1.2.3