]> granicus.if.org Git - git/commit
protocol: advertise multiple supported versions
authorJosh Steadmon <steadmon@google.com>
Thu, 20 Dec 2018 21:58:08 +0000 (13:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Dec 2018 21:24:00 +0000 (13:24 -0800)
commit6da1f1a92046b3a8b15fda3ee6885335ff3c61ab
tree68a4a8f7207c50a5a3cbf01e0100f2ea580acb39
parentb21ebb671bb7dea8d342225f0d66c41f4e54d5ca
protocol: advertise multiple supported versions

Currently the client advertises that it supports the wire protocol
version set in the protocol.version config. However, not all services
support the same set of protocol versions. For example, git-receive-pack
supports v1 and v0, but not v2. If a client connects to git-receive-pack
and requests v2, it will instead be downgraded to v0. Other services,
such as git-upload-archive, do not do any version negotiation checks.

This patch creates a protocol version registry. Individual client and
server programs register all the protocol versions they support prior to
communicating with a remote instance. Versions should be listed in
preference order; the version specified in protocol.version will
automatically be moved to the front of the registry.

The protocol version registry is passed to remote helpers via the
GIT_PROTOCOL environment variable.

Clients now advertise the full list of registered versions. Servers
select the first allowed version from this advertisement.

Additionally, remove special cases around advertising version=0.
Previously we avoided adding version advertisements to the client's
initial connection request if the client wanted version=0. However,
including these advertisements does not change the version negotiation
behavior, so it's better to have simpler code. As a side effect, this
means that client operations over SSH will always include a
"SendEnv=GIT_PROTOCOL" option on the SSH command line.

While we're at it, remove unnecessary externs from function declarations
in protocol.h.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
21 files changed:
builtin/archive.c
builtin/clone.c
builtin/fetch-pack.c
builtin/fetch.c
builtin/ls-remote.c
builtin/pull.c
builtin/push.c
builtin/receive-pack.c
builtin/send-pack.c
builtin/upload-archive.c
builtin/upload-pack.c
connect.c
protocol.c
protocol.h
remote-curl.c
t/t5551-http-fetch-smart.sh
t/t5570-git-daemon.sh
t/t5601-clone.sh
t/t5700-protocol-v1.sh
t/t5702-protocol-v2.sh
transport-helper.c