chiark / gitweb /
git-cache-proxy: Handle extra-parameters for git protocol v2
authorAnthony PERARD <anthony.perard@citrix.com>
Thu, 22 Jun 2023 14:46:53 +0000 (15:46 +0100)
committerSean Whitton <spwhitton@spwhitton.name>
Thu, 26 Sep 2024 16:01:47 +0000 (17:01 +0100)
commiteef5d90bf41a7f820d3d02b05ea3c21f9f920e8c
tree06b3e1767c9eee9104edbc950f8b0d85429e287e
parent743fd0c57c1192d9df376d483b48aad536bd8425
git-cache-proxy: Handle extra-parameters for git protocol v2

This patch allows git clients to communicate with the cache with the git
protocol version 2.

Even though the only described extra-parameters is "version=2", the protocol
describe how extra parameters are handled. `git-upload-pack` will just ignore
the ones it doesn't know about.

The first line of the git protocol is described at
https://github.com/git/git/blob/master/Documentation/gitprotocol-pack.txt
and "extra-parameters" has been implemented here.

These parameters can be passed down to `git-upload-pack` via
the environment variable GIT_PROTOCOL like a clone over ssh would do
(if the ssh server allows GIT_PROTOCOL env variables).

GIT_PROTOCOL is described in
https://github.com/git/git/blob/master/Documentation/git.txt

The reason we need to be able to handle V2 is to allow a shallow clone with an
sha1. Shallow clone seems to only work with a known ref with the v1 of the
protocol.

Example of command that fails when QEMU v8.1 tries to clone the subproject
"dtc" via meson:

    git fetch --depth 1 origin b6910bec11614980a21e46fbccc35934b671bd81

This command also fails when git isn't able to send the envvar GIT_PROTOCOL,
like when cloning over ssh (without git-cache-proxy).

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
scripts/git-cache-proxy