From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: git@jeffhostetler.com, gitster@pobox.com, jrnieder@gmail.com,
pclouds@gmail.com, peff@peff.net, sbeller@google.com,
stolee@gmail.com, jonathantanmy@google.com,
Brandon Williams <bmwill@google.com>
Subject: [PATCH v5 16/35] transport: convert transport_get_remote_refs to take a list of ref prefixes
Date: Wed, 14 Mar 2018 11:31:53 -0700 [thread overview]
Message-ID: <20180314183213.223440-17-bmwill@google.com> (raw)
In-Reply-To: <20180314183213.223440-1-bmwill@google.com>
Teach transport_get_remote_refs() to accept a list of ref prefixes,
which will be sent to the server for use in filtering when using
protocol v2. (This list will be ignored when not using protocol v2.)
Signed-off-by: Brandon Williams <bmwill@google.com>
---
builtin/clone.c | 2 +-
builtin/fetch.c | 4 ++--
builtin/ls-remote.c | 2 +-
builtin/remote.c | 2 +-
transport.c | 7 +++++--
transport.h | 12 +++++++++++-
6 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 284651797e..6e77d993fa 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1121,7 +1121,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (transport->smart_options && !deepen)
transport->smart_options->check_self_contained_and_connected = 1;
- refs = transport_get_remote_refs(transport);
+ refs = transport_get_remote_refs(transport, NULL);
if (refs) {
mapped_refs = wanted_peer_refs(refs, refspec);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 7bbcd26faf..850382f559 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -250,7 +250,7 @@ static void find_non_local_tags(struct transport *transport,
struct string_list_item *item = NULL;
for_each_ref(add_existing, &existing_refs);
- for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
+ for (ref = transport_get_remote_refs(transport, NULL); ref; ref = ref->next) {
if (!starts_with(ref->name, "refs/tags/"))
continue;
@@ -336,7 +336,7 @@ static struct ref *get_ref_map(struct transport *transport,
/* opportunistically-updated references: */
struct ref *orefs = NULL, **oref_tail = &orefs;
- const struct ref *remote_refs = transport_get_remote_refs(transport);
+ const struct ref *remote_refs = transport_get_remote_refs(transport, NULL);
if (refspec_count) {
struct refspec *fetch_refspec;
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index c4be98ab9e..c6e9847c5c 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -96,7 +96,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);
+ ref = transport_get_remote_refs(transport, NULL);
if (transport_disconnect(transport))
return 1;
diff --git a/builtin/remote.c b/builtin/remote.c
index d95bf904c3..d0b6ff6e29 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -862,7 +862,7 @@ static int get_remote_ref_states(const char *name,
if (query) {
transport = transport_get(states->remote, states->remote->url_nr > 0 ?
states->remote->url[0] : NULL);
- remote_refs = transport_get_remote_refs(transport);
+ remote_refs = transport_get_remote_refs(transport, NULL);
transport_disconnect(transport);
states->queried = 1;
diff --git a/transport.c b/transport.c
index 2e68010dd0..3f130518d2 100644
--- a/transport.c
+++ b/transport.c
@@ -1138,10 +1138,13 @@ int transport_push(struct transport *transport,
return 1;
}
-const struct ref *transport_get_remote_refs(struct transport *transport)
+const struct ref *transport_get_remote_refs(struct transport *transport,
+ const struct argv_array *ref_prefixes)
{
if (!transport->got_remote_refs) {
- transport->remote_refs = transport->vtable->get_refs_list(transport, 0, NULL);
+ transport->remote_refs =
+ transport->vtable->get_refs_list(transport, 0,
+ ref_prefixes);
transport->got_remote_refs = 1;
}
diff --git a/transport.h b/transport.h
index 731c78b679..83992a4257 100644
--- a/transport.h
+++ b/transport.h
@@ -178,7 +178,17 @@ int transport_push(struct transport *connection,
int refspec_nr, const char **refspec, int flags,
unsigned int * reject_reasons);
-const struct ref *transport_get_remote_refs(struct transport *transport);
+/*
+ * Retrieve refs from a remote.
+ *
+ * Optionally a list of ref prefixes can be provided which can be sent to the
+ * server (when communicating using protocol v2) to enable it to limit the ref
+ * advertisement. Since ref filtering is done on the server's end (and only
+ * when using protocol v2), this can return refs which don't match the provided
+ * ref_prefixes.
+ */
+const struct ref *transport_get_remote_refs(struct transport *transport,
+ const struct argv_array *ref_prefixes);
int transport_fetch_refs(struct transport *transport, struct ref *refs);
void transport_unlock_pack(struct transport *transport);
--
2.16.2.804.g6dcf76e118-goog
next prev parent reply other threads:[~2018-03-14 18:34 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 18:31 [PATCH v5 00/35] protocol version 2 Brandon Williams
2018-03-14 18:31 ` [PATCH v5 01/35] pkt-line: introduce packet_read_with_status Brandon Williams
2018-03-14 21:33 ` Junio C Hamano
2018-03-15 17:28 ` Brandon Williams
2018-03-15 18:37 ` Junio C Hamano
2018-03-14 18:31 ` [PATCH v5 02/35] pkt-line: allow peeking a packet line without consuming it Brandon Williams
2018-03-14 18:31 ` [PATCH v5 03/35] pkt-line: add delim packet support Brandon Williams
2018-03-14 18:31 ` [PATCH v5 04/35] upload-pack: convert to a builtin Brandon Williams
2018-03-14 18:31 ` [PATCH v5 05/35] upload-pack: factor out processing lines Brandon Williams
2018-03-14 18:31 ` [PATCH v5 06/35] transport: use get_refs_via_connect to get refs Brandon Williams
2018-03-14 18:31 ` [PATCH v5 07/35] connect: convert get_remote_heads to use struct packet_reader Brandon Williams
2018-03-14 18:31 ` [PATCH v5 08/35] connect: discover protocol version outside of get_remote_heads Brandon Williams
2018-03-14 18:31 ` [PATCH v5 09/35] transport: store protocol version Brandon Williams
2018-03-14 18:31 ` [PATCH v5 10/35] protocol: introduce enum protocol_version value protocol_v2 Brandon Williams
2018-03-14 18:31 ` [PATCH v5 11/35] test-pkt-line: introduce a packet-line test helper Brandon Williams
2018-03-14 18:31 ` [PATCH v5 12/35] serve: introduce git-serve Brandon Williams
2018-03-14 22:01 ` Junio C Hamano
2018-03-15 17:27 ` Brandon Williams
2018-03-14 18:31 ` [PATCH v5 13/35] ls-refs: introduce ls-refs server command Brandon Williams
2018-03-14 18:31 ` [PATCH v5 14/35] connect: request remote refs using v2 Brandon Williams
2018-03-14 18:31 ` [PATCH v5 15/35] transport: convert get_refs_list to take a list of ref prefixes Brandon Williams
2018-03-14 18:31 ` Brandon Williams [this message]
2018-03-14 18:31 ` [PATCH v5 17/35] ls-remote: pass ref prefixes when requesting a remote's refs Brandon Williams
2018-03-14 18:31 ` [PATCH v5 18/35] fetch: pass ref prefixes when fetching Brandon Williams
2018-03-14 18:31 ` [PATCH v5 19/35] push: pass ref prefixes when pushing Brandon Williams
2018-03-14 18:31 ` [PATCH v5 20/35] upload-pack: introduce fetch server command Brandon Williams
2018-03-14 18:31 ` [PATCH v5 21/35] fetch-pack: perform a fetch using v2 Brandon Williams
2018-03-14 18:31 ` [PATCH v5 22/35] fetch-pack: support shallow requests Brandon Williams
2018-03-14 18:32 ` [PATCH v5 23/35] connect: refactor git_connect to only get the protocol version once Brandon Williams
2018-03-14 18:32 ` [PATCH v5 24/35] connect: don't request v2 when pushing Brandon Williams
2018-03-14 18:32 ` [PATCH v5 25/35] transport-helper: remove name parameter Brandon Williams
2018-03-14 18:32 ` [PATCH v5 26/35] transport-helper: refactor process_connect_service Brandon Williams
2018-03-14 18:32 ` [PATCH v5 27/35] transport-helper: introduce stateless-connect Brandon Williams
2018-03-14 18:32 ` [PATCH v5 28/35] pkt-line: add packet_buf_write_len function Brandon Williams
2018-03-14 18:32 ` [PATCH v5 29/35] remote-curl: create copy of the service name Brandon Williams
2018-03-14 18:32 ` [PATCH v5 30/35] remote-curl: store the protocol version the server responded with Brandon Williams
2018-03-14 18:32 ` [PATCH v5 31/35] http: allow providing extra headers for http requests Brandon Williams
2018-03-14 18:32 ` [PATCH v5 32/35] http: don't always add Git-Protocol header Brandon Williams
2018-03-14 18:32 ` [PATCH v5 33/35] http: eliminate "# service" line when using protocol v2 Brandon Williams
2018-03-14 18:32 ` [PATCH v5 34/35] remote-curl: implement stateless-connect command Brandon Williams
2018-03-14 18:32 ` [PATCH v5 35/35] remote-curl: don't request v2 when pushing Brandon Williams
2018-03-15 17:31 ` [PATCH v6 00/35] protocol version 2 Brandon Williams
2018-03-15 17:31 ` [PATCH v6 01/35] pkt-line: introduce packet_read_with_status Brandon Williams
2018-03-15 17:31 ` [PATCH v6 02/35] pkt-line: allow peeking a packet line without consuming it Brandon Williams
2018-03-15 17:31 ` [PATCH v6 03/35] pkt-line: add delim packet support Brandon Williams
2018-03-15 17:31 ` [PATCH v6 04/35] upload-pack: convert to a builtin Brandon Williams
2018-03-15 17:31 ` [PATCH v6 05/35] upload-pack: factor out processing lines Brandon Williams
2018-03-15 17:31 ` [PATCH v6 06/35] transport: use get_refs_via_connect to get refs Brandon Williams
2018-03-15 17:31 ` [PATCH v6 07/35] connect: convert get_remote_heads to use struct packet_reader Brandon Williams
2018-03-27 15:27 ` Duy Nguyen
2018-03-27 16:11 ` Jeff King
2018-03-27 16:25 ` Duy Nguyen
2018-03-27 16:39 ` Duy Nguyen
2018-03-27 16:58 ` Brandon Williams
2018-03-15 17:31 ` [PATCH v6 08/35] connect: discover protocol version outside of get_remote_heads Brandon Williams
2018-03-15 17:31 ` [PATCH v6 09/35] transport: store protocol version Brandon Williams
2018-03-15 17:31 ` [PATCH v6 10/35] protocol: introduce enum protocol_version value protocol_v2 Brandon Williams
2018-03-15 17:31 ` [PATCH v6 11/35] test-pkt-line: introduce a packet-line test helper Brandon Williams
2018-03-15 17:31 ` [PATCH v6 12/35] serve: introduce git-serve Brandon Williams
2018-03-15 17:31 ` [PATCH v6 13/35] ls-refs: introduce ls-refs server command Brandon Williams
2018-03-15 17:31 ` [PATCH v6 14/35] connect: request remote refs using v2 Brandon Williams
2018-03-15 17:31 ` [PATCH v6 15/35] transport: convert get_refs_list to take a list of ref prefixes Brandon Williams
2018-03-15 17:31 ` [PATCH v6 16/35] transport: convert transport_get_remote_refs " Brandon Williams
2018-03-15 17:31 ` [PATCH v6 17/35] ls-remote: pass ref prefixes when requesting a remote's refs Brandon Williams
2018-03-15 17:31 ` [PATCH v6 18/35] fetch: pass ref prefixes when fetching Brandon Williams
2018-03-15 17:31 ` [PATCH v6 19/35] push: pass ref prefixes when pushing Brandon Williams
2018-03-15 17:31 ` [PATCH v6 20/35] upload-pack: introduce fetch server command Brandon Williams
2018-03-15 17:31 ` [PATCH v6 21/35] fetch-pack: perform a fetch using v2 Brandon Williams
2018-03-15 17:31 ` [PATCH v6 22/35] fetch-pack: support shallow requests Brandon Williams
2018-03-15 17:31 ` [PATCH v6 23/35] connect: refactor git_connect to only get the protocol version once Brandon Williams
2018-03-15 17:31 ` [PATCH v6 24/35] connect: don't request v2 when pushing Brandon Williams
2018-03-15 17:31 ` [PATCH v6 25/35] transport-helper: remove name parameter Brandon Williams
2018-03-15 17:31 ` [PATCH v6 26/35] transport-helper: refactor process_connect_service Brandon Williams
2018-03-15 17:31 ` [PATCH v6 27/35] transport-helper: introduce stateless-connect Brandon Williams
2018-03-15 17:31 ` [PATCH v6 28/35] pkt-line: add packet_buf_write_len function Brandon Williams
2018-03-15 17:31 ` [PATCH v6 29/35] remote-curl: create copy of the service name Brandon Williams
2018-03-15 17:31 ` [PATCH v6 30/35] remote-curl: store the protocol version the server responded with Brandon Williams
2018-03-15 17:31 ` [PATCH v6 31/35] http: allow providing extra headers for http requests Brandon Williams
2018-03-15 17:31 ` [PATCH v6 32/35] http: don't always add Git-Protocol header Brandon Williams
2018-03-15 17:31 ` [PATCH v6 33/35] http: eliminate "# service" line when using protocol v2 Brandon Williams
2018-03-15 17:31 ` [PATCH v6 34/35] remote-curl: implement stateless-connect command Brandon Williams
2018-03-15 17:31 ` [PATCH v6 35/35] remote-curl: don't request v2 when pushing Brandon Williams
2018-03-30 9:29 ` [PATCH] {fetch,upload}-pack: clearly mark unreachable v2 code Ævar Arnfjörð Bjarmason
2018-03-30 19:03 ` Brandon Williams
2018-03-30 19:06 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180314183213.223440-17-bmwill@google.com \
--to=bmwill@google.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).