Skip to content

Commit ecc3e53

Browse files
bmwillgitster
authored andcommitted
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>
1 parent bbc39d4 commit ecc3e53

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Documentation/technical/protocol-v2.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,13 @@ header.
393393
1 - pack data
394394
2 - progress messages
395395
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static struct protocol_capability capabilities[] = {
5656
{ "agent", agent_advertise, NULL },
5757
{ "ls-refs", always_advertise, ls_refs },
5858
{ "fetch", upload_pack_advertise, upload_pack_v2 },
59+
{ "server-option", always_advertise, NULL },
5960
};
6061

6162
static void advertise_capabilities(void)

t/t5701-git-serve.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ test_expect_success 'test capability advertisement' '
1010
agent=git/$(git version | cut -d" " -f3)
1111
ls-refs
1212
fetch=shallow
13+
server-option
1314
0000
1415
EOF
1516
@@ -173,4 +174,24 @@ test_expect_success 'symrefs parameter' '
173174
test_cmp actual expect
174175
'
175176

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+
176197
test_done

0 commit comments

Comments
 (0)