Allow to enable git protocol version 2 for upload pack

When receive.enableProtocolV2 is set to true, set the necessary extra
parameters on the UploadPack to tell JGit to handle the request with
protocol v2.

Note that according to JGit's implementation, the git config on the
repository on the server must also be configured to use protocol v2.

This can be achieved either by setting it globally in the gerrit
user's ~/.gitconfig or per repository in the repository's .git/config:

  [protocol]
    version = 2

Test plan:
  - Set protocol.version to 2 in the project's server-side config (or
    in the gerrit user's ~/.gitconfig)

  - Clone the project over SSH or HTTP

  - From the client, run:
    GIT_TRACE_PACKET=1 git -c protocol.version=2 ls-remote

    (one can also configure this permanently on the local project by
     running `git config protocol.version 2`)

  - Observe the packet output including:
    git< version 2

Feature: Issue 9046
Helped-by: David Ostrovsky <david@ostrovsky.org>
Helped-by: Jonathan Nieder <jrn@google.com>
Change-Id: I30290e8f060c1ee11b170aac2baeed10f213aad1
This commit is contained in:
David Pursehouse
2018-09-26 21:10:59 +09:00
parent 48827f6916
commit 437d7ef616
5 changed files with 36 additions and 1 deletions

View File

@@ -3806,6 +3806,20 @@ link:https://www.gnupg.org/documentation/manuals/gnupg/OpenPGP-Key-Management.ht
If no keys are specified, web-of-trust checks are disabled. This is the
default behavior.
[[receive.enableProtocolV2]]receive.enableProtocolV2::
+
Enable support for git protocol version 2.
+
When this option is enabled, clients may send upload pack using git
protocol version 2.
+
The repository must also be configured on the server side to use protocol
version 2 by setting `protocol.version = 2` either in the gerrit user's
`~/.gitconfig` file (which will enable it for all repositories) or on
a per repository basis by setting the option in the `.git/config` file
of the repository.
+
Defaults to false, git protocol version 2 is not enabled.
[[repository]]
=== Section repository