Documentation: document Extra Parameters

Document the server support for Extra Parameters, additional information that the client can send in its first message to the server during a Git client-server interaction. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Oct 16, 2017 at 10:55 UTC 6464679d9620d91b639e2681b9cc6473f3856d09
2 files changed +44 -7
Documentation/technical/http-protocol.txt
+8
@@ -219,6 +219,10 @@ smart server reply:
219 S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
220 S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
221
222 +The client may send Extra Parameters (see
223 +Documentation/technical/pack-protocol.txt) as a colon-separated string
224 +in the Git-Protocol HTTP header.
225 +
226 Dumb Server Response
227 ^^^^^^^^^^^^^^^^^^^^
228 Dumb servers MUST respond with the dumb server reply format.
@@ -269,7 +273,11 @@ the C locale ordering. The stream SHOULD include the default ref
273 named `HEAD` as the first ref. The stream MUST include capability
274 declarations behind a NUL on the first ref.
275
276 +The returned response contains "version 1" if "version=1" was sent as an
277 +Extra Parameter.
278 +
279 smart_reply = PKT-LINE("# service=$servicename" LF)
280 + *1("version 1")
281 ref_list
282 "0000"
283 ref_list = empty_list / non_empty_list
Documentation/technical/pack-protocol.txt
+36 -7
@@ -39,6 +39,19 @@ communicates with that invoked process over the SSH connection.
39 The file:// transport runs the 'upload-pack' or 'receive-pack'
40 process locally and communicates with it over a pipe.
41
42 +Extra Parameters
43 +----------------
44 +
45 +The protocol provides a mechanism in which clients can send additional
46 +information in its first message to the server. These are called "Extra
47 +Parameters", and are supported by the Git, SSH, and HTTP protocols.
48 +
49 +Each Extra Parameter takes the form of `<key>=<value>` or `<key>`.
50 +
51 +Servers that receive any such Extra Parameters MUST ignore all
52 +unrecognized keys. Currently, the only Extra Parameter recognized is
53 +"version=1".
54 +
55 Git Transport
56 -------------
57
@@ -46,18 +59,25 @@ The Git transport starts off by sending the command and repository
59 on the wire using the pkt-line format, followed by a NUL byte and a
60 hostname parameter, terminated by a NUL byte.
61
49 - 0032git-upload-pack /project.git\0host=myserver.com\0
62 + 0033git-upload-pack /project.git\0host=myserver.com\0
63 +
64 +The transport may send Extra Parameters by adding an additional NUL
65 +byte, and then adding one or more NUL-terminated strings:
66 +
67 + 003egit-upload-pack /project.git\0host=myserver.com\0\0version=1\0
68
69 --
52 - git-proto-request = request-command SP pathname NUL [ host-parameter NUL ]
70 + git-proto-request = request-command SP pathname NUL
71 + [ host-parameter NUL ] [ NUL extra-parameters ]
72 request-command = "git-upload-pack" / "git-receive-pack" /
73 "git-upload-archive" ; case sensitive
74 pathname = *( %x01-ff ) ; exclude NUL
75 host-parameter = "host=" hostname [ ":" port ]
76 + extra-parameters = 1*extra-parameter
77 + extra-parameter = 1*( %x01-ff ) NUL
78 --
79
59 -Only host-parameter is allowed in the git-proto-request. Clients
60 -MUST NOT attempt to send additional parameters. It is used for the
80 +host-parameter is used for the
81 git-daemon name based virtual hosting. See --interpolated-path
82 option to git daemon, with the %H/%CH format characters.
83
@@ -117,6 +137,12 @@ we execute it without the leading '/'.
137 v
138 ssh user@example.com "git-upload-pack '~alice/project.git'"
139
140 +Depending on the value of the `protocol.version` configuration variable,
141 +Git may attempt to send Extra Parameters as a colon-separated string in
142 +the GIT_PROTOCOL environment variable. This is done only if
143 +the `ssh.variant` configuration variable indicates that the ssh command
144 +supports passing environment variables as an argument.
145 +
146 A few things to remember here:
147
148 - The "command name" is spelled with dash (e.g. git-upload-pack), but
@@ -137,11 +163,13 @@ Reference Discovery
163 -------------------
164
165 When the client initially connects the server will immediately respond
140 -with a listing of each reference it has (all branches and tags) along
166 +with a version number (if "version=1" is sent as an Extra Parameter),
167 +and a listing of each reference it has (all branches and tags) along
168 with the object name that each reference currently points to.
169
143 - $ echo -e -n "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" |
170 + $ echo -e -n "0044git-upload-pack /schacon/gitbook.git\0host=example.com\0\0version=1\0" |
171 nc -v example.com 9418
172 + 000aversion 1
173 00887217a7c7e582c46cec22a130adf4b9d7d950fba0 HEAD\0multi_ack thin-pack
174 side-band side-band-64k ofs-delta shallow no-progress include-tag
175 00441d3fcd5ced445d1abc402225c0b8a1299641f497 refs/heads/integration
@@ -165,7 +193,8 @@ immediately after the ref itself, if presented. A conforming server
193 MUST peel the ref if it's an annotated tag.
194
195 ----
168 - advertised-refs = (no-refs / list-of-refs)
196 + advertised-refs = *1("version 1")
197 + (no-refs / list-of-refs)
198 *shallow
199 flush-pkt
200