Skip to content

Commit 6464679

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94b8ae5 commit 6464679

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

Documentation/technical/http-protocol.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ smart server reply:
219219
S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
220220
S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
221221

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+
222226
Dumb Server Response
223227
^^^^^^^^^^^^^^^^^^^^
224228
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
269273
named `HEAD` as the first ref. The stream MUST include capability
270274
declarations behind a NUL on the first ref.
271275

276+
The returned response contains "version 1" if "version=1" was sent as an
277+
Extra Parameter.
278+
272279
smart_reply = PKT-LINE("# service=$servicename" LF)
280+
*1("version 1")
273281
ref_list
274282
"0000"
275283
ref_list = empty_list / non_empty_list

Documentation/technical/pack-protocol.txt

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,45 @@ communicates with that invoked process over the SSH connection.
3939
The file:// transport runs the 'upload-pack' or 'receive-pack'
4040
process locally and communicates with it over a pipe.
4141

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+
4255
Git Transport
4356
-------------
4457

4558
The Git transport starts off by sending the command and repository
4659
on the wire using the pkt-line format, followed by a NUL byte and a
4760
hostname parameter, terminated by a NUL byte.
4861

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
5068

5169
--
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 ]
5372
request-command = "git-upload-pack" / "git-receive-pack" /
5473
"git-upload-archive" ; case sensitive
5574
pathname = *( %x01-ff ) ; exclude NUL
5675
host-parameter = "host=" hostname [ ":" port ]
76+
extra-parameters = 1*extra-parameter
77+
extra-parameter = 1*( %x01-ff ) NUL
5778
--
5879

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
6181
git-daemon name based virtual hosting. See --interpolated-path
6282
option to git daemon, with the %H/%CH format characters.
6383

@@ -117,6 +137,12 @@ we execute it without the leading '/'.
117137
v
118138
ssh [email protected] "git-upload-pack '~alice/project.git'"
119139

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+
120146
A few things to remember here:
121147

122148
- The "command name" is spelled with dash (e.g. git-upload-pack), but
@@ -137,11 +163,13 @@ Reference Discovery
137163
-------------------
138164

139165
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
141168
with the object name that each reference currently points to.
142169

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" |
144171
nc -v example.com 9418
172+
000aversion 1
145173
00887217a7c7e582c46cec22a130adf4b9d7d950fba0 HEAD\0multi_ack thin-pack
146174
side-band side-band-64k ofs-delta shallow no-progress include-tag
147175
00441d3fcd5ced445d1abc402225c0b8a1299641f497 refs/heads/integration
@@ -165,7 +193,8 @@ immediately after the ref itself, if presented. A conforming server
165193
MUST peel the ref if it's an annotated tag.
166194

167195
----
168-
advertised-refs = (no-refs / list-of-refs)
196+
advertised-refs = *1("version 1")
197+
(no-refs / list-of-refs)
169198
*shallow
170199
flush-pkt
171200

0 commit comments

Comments
 (0)