git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Lana Deere <lana.deere@gmail.com>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
	git@vger.kernel.org
Subject: Re: 2.37.2 can't "git pull" but 2.18.0 can
Date: Thu, 8 Sep 2022 14:14:07 -0400	[thread overview]
Message-ID: <Yxow7zrYF/xOijVr@coredump.intra.peff.net> (raw)
In-Reply-To: <CA+4x=b-SqzGfeTu4c8akk3quYF7ORZ5jYCpey5221H8=+_PfRg@mail.gmail.com>

On Thu, Sep 08, 2022 at 12:46:14PM -0400, Lana Deere wrote:

> With an explicit -c protocol.version=0 on the 2.37.2 git command line,
> the pull is successful.  For what it's worth, the server git is still
> 2.18.0 in all of these cases.  Only the client side is being tested so
> far.  I will try to gather the packet traces and see if there's a
> problem sharing them.  Will this mailing list allow attachments?

You can send attachments to the list as long as the total mail size is
under 100kb. But to keep the list in the loop: Lana sent me the traces
off-list, because naturally they have a bunch of semi-private ref names.

I was able to see the problem from the traces: the v2 protocol has an
extension to tell the server to limit the advertisement only to branches
we're interested in. And it does so based on the configured refspec. As
Dscho noted earlier in the thread, the upstream branch you want isn't in
the refspec. We try to add that branch explicitly to what we're
fetching, but I think that happens too late to affect the ref-prefix
limiting. So the server is asked not to advertise the ref, and from the
client's perspective, it looks like the branch does not exist on the
server.

Here's a minimal reproduction:

  # a server with two branches
  git init server
  (
    cd server
    git checkout -b branch1
    git commit --allow-empty -m foo
    git branch branch2
  )

  # and a client which points its origin there,
  # and has local copies of both branches, tracking
  # the upstream versions
  git clone server client
  cd client
  git checkout branch1
  git checkout branch2

  # but afterwards, the client narrows its refspec to only fetch branch1
  git config remote.origin.fetch +refs/heads/branch1:refs/remotes/origin/branch1

  # pulling branch2 with v0 works
  git -c protocol.version=0 pull

  # but does not with v2, because the ref-prefix extension tells the
  # server not to advertise anything outside of branch1
  git -c protocol.version=2 pull

This is a bug which we should fix. But in the meantime the obvious
workaround is to expand the default refspec to cover both branches.
Obviously the default of fetching "refs/heads/*" would work, but if you
want to keep it limited for some reason, you can add the second branch
explicitly. In the example above, it would be:

  git config --add remote.origin.fetch +refs/heads/branch2:refs/remotes/origin/branch2

-Peff

  reply	other threads:[~2022-09-08 18:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 19:27 2.37.2 can't "git pull" but 2.18.0 can Lana Deere
2022-09-02 20:16 ` brian m. carlson
2022-09-06 18:26   ` Lana Deere
2022-09-07 12:59     ` Johannes Schindelin
2022-09-07 15:59       ` Lana Deere
2022-09-08 18:20       ` Jeff King
2022-09-03  1:07 ` Jeff King
2022-09-06 19:37   ` Lana Deere
2022-09-07  2:11     ` Đoàn Trần Công Danh
2022-09-07 15:56       ` Lana Deere
2022-09-07 18:21         ` Jeff King
2022-09-07 18:53           ` Lana Deere
2022-09-07 21:10             ` Jeff King
2022-09-08 16:46               ` Lana Deere
2022-09-08 18:14                 ` Jeff King [this message]
2022-09-08 19:23                   ` [PATCH 0/2] v2 protocol can't "git pull" with restricted refspec Jeff King
2022-09-08 19:24                     ` [PATCH 1/2] fetch: stop checking for NULL transport->remote in do_fetch() Jeff King
2022-09-08 19:26                     ` [PATCH 2/2] fetch: add branch.*.merge to default ref-prefix extension Jeff King
2022-09-08 20:36                       ` Junio C Hamano
2022-09-08 20:48                         ` Junio C Hamano
2022-09-09  2:17                           ` Jeff King
2022-09-09  5:23                             ` Junio C Hamano
2022-09-11  5:08                               ` Jeff King
2022-09-09 17:32                   ` 2.37.2 can't "git pull" but 2.18.0 can Lana Deere
2022-09-09 18:27                     ` Junio C Hamano
2022-09-12 14:58                       ` Lana Deere
2022-09-13  0:28                         ` Jeff King
2022-09-05 10:25 ` Johannes Schindelin
2022-09-06 18:38   ` Lana Deere
2022-09-07 10:20     ` Johannes Schindelin
2022-09-07 16:01       ` Lana Deere

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yxow7zrYF/xOijVr@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lana.deere@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).