git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git Push Always uses Protocol Version 0

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2024, 18:52 UTC
Message-ID
<xmqqa5oxurnj.fsf@gitster.g>
In-Reply-To
<FD545E92-18EF-44B5-A7D5-61ECADD880E6@gmail.com>
Zsolt Imre <imrexzsolt@gmail.com> writes:
Show 12 quoted lines
> I'm not entirely sure if this is a bug or I am missing something,
> but I thought I would share in the hope someone can help out. I'm
> playing around with Git and trying to implement a git server that
> communicates over HTTP and supports Git protocol version 2 *only*.
>
> When I `clone` a repository, the Git client (version 2.43.0),
> after fetching the capabilities using protocol version 2, it
> proceeds to fetch the refs, again, via protocol version 2 using
> the `ls-refs` command.  However, when I try to `push` my changes
> to the repo, the Git client refuses to use protocol version 2 and
> tries to obtain the ref list using protocol version 0, even if I
> pass in the `-c protocol.version=2` command line argument.

Given that v0 and v1 in the push direction behave exactly the same, and there has been no need to add features that were not supportable in v1 in the push direction, it is not surprising to see this code

        int cmd_send_pack(int argc, const char **argv, const char *prefix)
        {
		...
                switch (discover_version(&reader)) {
                case protocol_v2:
                        die("support for protocol v2 not implemented yet");
                        break;

in https://github.com/git/git/blob/master/builtin/send-pack.c#L282 and also

        int cmd_receive_pack(int argc, const char **argv, const char *prefix)
        {
		...
                switch (determine_protocol_version_server()) {
                case protocol_v2:
                        /*
                         * push support for protocol v2 has not been implemented yet,
                         * so ignore the request to use v2 and fallback to using v0.
                         */
                        break;
in https://github.com/git/git/blob/master/builtin/receive-pack.c#L2538

that tells the receiving end to demote "v2" request down to "v0", and have the pushing end honor that choice.

What specifically did you want to gain by using protocol version 2 in the "push" direction that you cannot do with the current versions?

Previous: Zsolt ImreNext: Zsolt Imre
Message 2 of 4 in “Git Push Always uses Protocol Version 0”
  1. Zsolt ImreJan 22, 2024
  2. Junio C HamanoJan 22, 2024
  3. Zsolt ImreJan 22, 2024
  4. Jeff KingJan 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.