From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Kevin Phillips <thefriendlycoder@gmail.com>,
git@vger.kernel.org, Jonathan Tan <jonathantanmy@google.com>,
Emily Shaffer <emilyshaffer@google.com>
Cc: Jeff King <peff@peff.net>,
Brandon Williams <bwilliamseng@gmail.com>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Weird interaction between Git protocol versions and git:// and https:// URLs (was: Re: Bug with Git shallow clones and submodules)
Date: Thu, 2 Sep 2021 09:49:38 -0400 [thread overview]
Message-ID: <542a68a5-d439-921e-2691-bb8890584f27@gmail.com> (raw)
In-Reply-To: <1a98c659-e7db-50a6-faf3-b3b4c15df679@gmail.com>
Hi everyone,
Le 2021-08-15 à 10:31, Philippe Blain a écrit :
> 5. It falls back to fetching the needed commit by its hash:
>
> start git fetch origin 78bc27846101e481438a98c68cac47e4476085c0
>
> 6. The server at https://dpdk.org/git/dpdk-stable refuses this request and you get
>
> error: Server does not allow request for unadvertised object 78bc27846101e481438a98c68cac47e4476085c0
>
> OK so why does the server refuses the request ? If you take a look at [4], you will
> understand that it's probably because the configs 'uploadpack.allowReachableSHA1InWant'
> and 'uploadpack.allowAnySHA1InWant' are both false (i.e. their default value) on the
> https://dpdk.org/git/dpdk-stable server. So the behaviour here is not a bug, it's
> working as it should (but leads to a bad experience for you).
>
> What is not unfortunately not mentioned in the documentation at [4]
> is that the two configs that I mention above only apply if version 0 of the Git transfer
> protocol is in effect. So this would mean that even though we specify '-c protocol.version=2'
> in the 'git clone' command in my script, the server uses protocol v0. Protocol v2 works
> starting in Git 2.18, so let's check what version is running at dpdk.org:
>
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote https://dpdk.org/git/dpdk-stable 2>&1 | grep agent
> packet: git< 6ee0521feb765d9105241a3f6693762c471655cf HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/default agent=git/2.20.1
>
> OK, it's running Git 2.20.1. And the list of capabilities above implies that it's responding
> with protocol v0, even if my local Git version if 2.29, which defaults to protocol v2. If
> it were responding with protocol v2, we would see:
>
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote https://github.com/git/git 2>&1 | grep agent
> packet: git< agent=git/github-g78b452413e8b # server version
> packet: git< agent=git/github-g78b452413e8b
> packet: git> agent=git/2.29.2 # client version
> packet: git< agent=git/2.29.2
>
> And grepping for "version" would confirm it:
>
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote https://github.com/git/git 2>&1 | grep version
> packet: git< version 2
> packet: git< version 2
>
> I can't explain why the server refuses to talk with protocol v2. Maybe Jonathan (CC-ed),
> who worked on the implementation of protocol v2, would be able to explain that.
I'm sorry to bump this, but I would really like to understand what is going on here.
I'm not familiar at all with the protocol code, but my understanding was that after
Git 2.18, if a client requested protocol v2, the server would answer with v2 (at least
for git:// and http[s]://, and also for ssh:// if AcceptEnv is correctly configured).
Here, Git 2.20.1 at https://dpdk.org/git/dpdk-stable answers with v0 for https://,
but with v2 for git:// !
>
> And it gets weirder. If you instead use the Git URL (instead of the HTTPS URL)
> for the dpdk-stable submodule [2], then the server responds with protocol v2!
>
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote git://dpdk.org/dpdk-stable 2>&1 | grep agent
> packet: git< agent=git/2.20.1
> packet: git> agent=git/2.29.2
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote git://dpdk.org/dpdk-stable 2>&1 | grep version
> packet: git> git-upload-pack /dpdk-stable\0host=dpdk.org\0\0version=2\0
> packet: git< version 2
>
> And indeed, if you use the 'git://' URL in the 'git submodule add' command in my reproducer
> script, it succeeds !
>
> It don't understand this behaviour either.
>
--- snip ---
>
> P.S. for Jonathan I noticed some additional weirdness while debugging this:
> Some servers respond with a different Git version depending on the protocol:
>
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote git://gcc.gnu.org/git/gcc.git 2>&1 | grep -E 'agent|version '
> packet: git< version 2
> packet: git< agent=git/2.26.2
> packet: git> agent=git/2.29.2
> $ GIT_TRACE_PACKET=1 GIT_TRACE_BARE=1 git ls-remote https://gcc.gnu.org/git/gcc.git 2>&1 | grep agent -E 'agent|version '
> packet: git< 882f1d58bfa56737ff2de84c3cd1e0acfc318b86 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2.27.0
>
> Here again, with HTTPS we fall back to protocol v0. The same behaviour happens
> with git://sourceware.org/git/binutils-gdb.git...
This is also puzzling to me...
Thanks,
Philippe.
next prev parent reply other threads:[~2021-09-02 13:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 14:59 Bug with Git shallow clones and submodules Kevin Phillips
2021-08-15 14:31 ` Philippe Blain
2021-09-02 13:49 ` Philippe Blain [this message]
2021-09-04 12:57 ` Weird interaction between Git protocol versions and git:// and https:// URLs (was: Re: Bug with Git shallow clones and submodules) Jeff King
2021-09-04 14:51 ` Konstantin Ryabitsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=542a68a5-d439-921e-2691-bb8890584f27@gmail.com \
--to=levraiphilippeblain@gmail.com \
--cc=bwilliamseng@gmail.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
--cc=thefriendlycoder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).