ls-remote: send server options when using protocol v2

Teach ls-remote to optionally accept server options by specifying them
on the cmdline via '-o' or '--server-option'.  These server options are
sent to the remote end when querying for the remote end's refs using
protocol version 2.

If communicating using a protocol other than v2 the provided options are
ignored and not sent to the remote end.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams
2018-04-23 15:46:23 -07:00
committed by Junio C Hamano
parent ecc3e5342d
commit ff473221b4
7 changed files with 46 additions and 3 deletions

View File

@ -154,6 +154,22 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
test_cmp actual expect
'
test_expect_success 'server-options are sent when using ls-remote' '
test_when_finished "rm -f log" &&
GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
ls-remote -o hello -o world "file://$(pwd)/file_parent" master >actual &&
cat >expect <<-EOF &&
$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
EOF
test_cmp actual expect &&
grep "server-option=hello" log &&
grep "server-option=world" log
'
test_expect_success 'clone with file:// using protocol v2' '
test_when_finished "rm -f log" &&