serve: introduce the server-option capability
Introduce the "server-option" capability to protocol version 2. This enables future clients the ability to send server specific options in command requests when using protocol version 2. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Apr 23, 2018 at 15:46 UTC
ecc3e5342de203fa2d84c4a49a46aaa87289534b
3 files changed
+32
Documentation/technical/protocol-v2.txt
+10
@@ -393,3 +393,13 @@ header.
393
1 - pack data
394
2 - progress messages
395
3 - fatal error message just before stream aborts
396
+
397
+ server-option
398
+~~~~~~~~~~~~~~~
399
+
400
+If advertised, indicates that any number of server specific options can be
401
+included in a request. This is done by sending each option as a
402
+"server-option=<option>" capability line in the capability-list section of
403
+a request.
404
+
405
+The provided options must not contain a NUL or LF character.
serve.c
+1
@@ -56,6 +56,7 @@ static struct protocol_capability capabilities[] = {
56
{ "agent", agent_advertise, NULL },
57
{ "ls-refs", always_advertise, ls_refs },
58
{ "fetch", upload_pack_advertise, upload_pack_v2 },
59
+ { "server-option", always_advertise, NULL },
60
};
61
62
static void advertise_capabilities(void)
t/t5701-git-serve.sh
+21
@@ -10,6 +10,7 @@ test_expect_success 'test capability advertisement' '
10
agent=git/$(git version | cut -d" " -f3)
11
ls-refs
12
fetch=shallow
13
+ server-option
14
0000
15
EOF
16
@@ -173,4 +174,24 @@ test_expect_success 'symrefs parameter' '
174
test_cmp actual expect
175
'
176
177
+test_expect_success 'sending server-options' '
178
+ test-pkt-line pack >in <<-EOF &&
179
+ command=ls-refs
180
+ server-option=hello
181
+ server-option=world
182
+ 0001
183
+ ref-prefix HEAD
184
+ 0000
185
+ EOF
186
+
187
+ cat >expect <<-EOF &&
188
+ $(git rev-parse HEAD) HEAD
189
+ 0000
190
+ EOF
191
+
192
+ git serve --stateless-rpc <in >out &&
193
+ test-pkt-line unpack <out >actual &&
194
+ test_cmp actual expect
195
+'
196
+
197
test_done