All of lore.kernel.org
 help / color / mirror / Atom feed
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 27/35] transport-helper: introduce stateless-connect
Date: Wed, 14 Mar 2018 11:32:04 -0700	[thread overview]
Message-ID: <20180314183213.223440-28-bmwill@google.com> (raw)
In-Reply-To: <20180314183213.223440-1-bmwill@google.com>

Introduce the transport-helper capability 'stateless-connect'.  This
capability indicates that the transport-helper can be requested to run
the 'stateless-connect' command which should attempt to make a
stateless connection with a remote end.  Once established, the
connection can be used by the git client to communicate with
the remote end natively in a stateless-rpc manner as supported by
protocol v2.  This means that the client must send everything the server
needs in a single request as the client must not assume any
state-storing on the part of the server or transport.

If a stateless connection cannot be established then the remote-helper
will respond in the same manner as the 'connect' command indicating that
the client should fallback to using the dumb remote-helper commands.

A future patch will implement the 'stateless-connect' capability in our
http remote-helper (remote-curl) so that protocol v2 can be used using
the http transport.

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 Documentation/gitremote-helpers.txt | 32 +++++++++++++++++++++++++++++
 transport-helper.c                  | 11 ++++++++++
 transport.c                         |  1 +
 transport.h                         |  6 ++++++
 4 files changed, 50 insertions(+)

diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt
index 4a584f3c5d..cd9b34d230 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -102,6 +102,14 @@ Capabilities for Pushing
 +
 Supported commands: 'connect'.
 
+'stateless-connect'::
+	Experimental; for internal use only.
+	Can attempt to connect to a remote server for communication
+	using git's wire-protocol version 2.  See the documentation
+	for the stateless-connect command for more information.
++
+Supported commands: 'stateless-connect'.
+
 'push'::
 	Can discover remote refs and push local commits and the
 	history leading up to them to new or existing remote refs.
@@ -136,6 +144,14 @@ Capabilities for Fetching
 +
 Supported commands: 'connect'.
 
+'stateless-connect'::
+	Experimental; for internal use only.
+	Can attempt to connect to a remote server for communication
+	using git's wire-protocol version 2.  See the documentation
+	for the stateless-connect command for more information.
++
+Supported commands: 'stateless-connect'.
+
 'fetch'::
 	Can discover remote refs and transfer objects reachable from
 	them to the local object store.
@@ -375,6 +391,22 @@ Supported if the helper has the "export" capability.
 +
 Supported if the helper has the "connect" capability.
 
+'stateless-connect' <service>::
+	Experimental; for internal use only.
+	Connects to the given remote service for communication using
+	git's wire-protocol version 2.  Valid replies to this command
+	are empty line (connection established), 'fallback' (no smart
+	transport support, fall back to dumb transports) and just
+	exiting with error message printed (can't connect, don't bother
+	trying to fall back).  After line feed terminating the positive
+	(empty) response, the output of the service starts.  Messages
+	(both request and response) must consist of zero or more
+	PKT-LINEs, terminating in a flush packet. The client must not
+	expect the server to store any state in between request-response
+	pairs.  After the connection ends, the remote helper exits.
++
+Supported if the helper has the "stateless-connect" capability.
+
 If a fatal error occurs, the program writes the error message to
 stderr and exits. The caller should expect that a suitable error
 message has been printed if the child closes the connection without
diff --git a/transport-helper.c b/transport-helper.c
index 830f21f0a9..aecbc4a845 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -12,6 +12,7 @@
 #include "argv-array.h"
 #include "refs.h"
 #include "transport-internal.h"
+#include "protocol.h"
 
 static int debug;
 
@@ -26,6 +27,7 @@ struct helper_data {
 		option : 1,
 		push : 1,
 		connect : 1,
+		stateless_connect : 1,
 		signed_tags : 1,
 		check_connectivity : 1,
 		no_disconnect_req : 1,
@@ -188,6 +190,8 @@ static struct child_process *get_helper(struct transport *transport)
 			refspecs[refspec_nr++] = xstrdup(arg);
 		} else if (!strcmp(capname, "connect")) {
 			data->connect = 1;
+		} else if (!strcmp(capname, "stateless-connect")) {
+			data->stateless_connect = 1;
 		} else if (!strcmp(capname, "signed-tags")) {
 			data->signed_tags = 1;
 		} else if (skip_prefix(capname, "export-marks ", &arg)) {
@@ -612,6 +616,13 @@ static int process_connect_service(struct transport *transport,
 	if (data->connect) {
 		strbuf_addf(&cmdbuf, "connect %s\n", name);
 		ret = run_connect(transport, &cmdbuf);
+	} else if (data->stateless_connect &&
+		   (get_protocol_version_config() == protocol_v2) &&
+		   !strcmp("git-upload-pack", name)) {
+		strbuf_addf(&cmdbuf, "stateless-connect %s\n", name);
+		ret = run_connect(transport, &cmdbuf);
+		if (ret)
+			transport->stateless_rpc = 1;
 	}
 
 	strbuf_release(&cmdbuf);
diff --git a/transport.c b/transport.c
index 9152a45b38..342db492ca 100644
--- a/transport.c
+++ b/transport.c
@@ -252,6 +252,7 @@ static int fetch_refs_via_pack(struct transport *transport,
 		data->options.check_self_contained_and_connected;
 	args.cloning = transport->cloning;
 	args.update_shallow = data->options.update_shallow;
+	args.stateless_rpc = transport->stateless_rpc;
 
 	if (!data->got_remote_heads)
 		refs_tmp = get_refs_via_connect(transport, 0, NULL);
diff --git a/transport.h b/transport.h
index 83992a4257..0e602d4d47 100644
--- a/transport.h
+++ b/transport.h
@@ -55,6 +55,12 @@ struct transport {
 	 */
 	unsigned cloning : 1;
 
+	/*
+	 * Indicates that the transport is connected via a half-duplex
+	 * connection and should operate in stateless-rpc mode.
+	 */
+	unsigned stateless_rpc : 1;
+
 	/*
 	 * These strings will be passed to the {pre, post}-receive hook,
 	 * on the remote side, if both sides support the push options capability.
-- 
2.16.2.804.g6dcf76e118-goog


  parent reply	other threads:[~2018-03-14 18:33 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 ` [PATCH v5 16/35] transport: convert transport_get_remote_refs " Brandon Williams
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 ` Brandon Williams [this message]
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-28-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.