summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-03-15 17:31:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-15 19:01:08 (GMT)
commitb4be74105febef5c6235e1e2f1e468e76166cad8 (patch)
treeeb61d2519d6f2ef3e3014dc1fd0d754a6b0a2934 /builtin
parent1af8ae1cfa44a3f3c3f1efb7f9ebe68bc0ce7578 (diff)
downloadgit-b4be74105febef5c6235e1e2f1e468e76166cad8.zip
git-b4be74105febef5c6235e1e2f1e468e76166cad8.tar.gz
git-b4be74105febef5c6235e1e2f1e468e76166cad8.tar.bz2
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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/ls-remote.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index c6e9847..4276bf9 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -2,6 +2,7 @@
#include "cache.h"
#include "transport.h"
#include "remote.h"
+#include "refs.h"
static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
@@ -43,6 +44,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
int show_symref_target = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
+ struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
struct remote *remote;
struct transport *transport;
@@ -74,8 +76,17 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
if (argc > 1) {
int i;
pattern = xcalloc(argc, sizeof(const char *));
- for (i = 1; i < argc; i++)
+ for (i = 1; i < argc; i++) {
+ const char *glob;
pattern[i - 1] = xstrfmt("*/%s", argv[i]);
+
+ glob = strchr(argv[i], '*');
+ if (glob)
+ argv_array_pushf(&ref_prefixes, "%.*s",
+ (int)(glob - argv[i]), argv[i]);
+ else
+ expand_ref_prefix(&ref_prefixes, argv[i]);
+ }
}
remote = remote_get(dest);
@@ -96,7 +107,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
if (uploadpack != NULL)
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
- ref = transport_get_remote_refs(transport, NULL);
+ ref = transport_get_remote_refs(transport, &ref_prefixes);
if (transport_disconnect(transport))
return 1;