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

Re: [PATCH 2/2] fetch: add branch.*.merge to default ref-prefix extension

From
Jeff King <peff@peff.net>
Date
Sep 9, 2022, 02:17 UTC
Message-ID
<YxqiJW4cSp4cBR22@coredump.intra.peff.net>
In-Reply-To
<xmqqtu5hoamx.fsf@gitster.g>
On Thu, Sep 08, 2022 at 01:48:38PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> The new code assumes that branch.<name>.merge is a full refname, and
> strvec_push() is the right thing to do, when we add the knowledge
> that the current branch we are on by default merges with their
> refs/heads/frotz.  We just ask them to advertise refs/heads/frotz
> and they do not need to advertise refs/tags/frotz etc. let alone
> refs/tags/refs/heads/frotz so using expand_ref_prefix() here is
> wrong.

Right. When I was writing the patch I had no inkling that branch.*.merge could ever be anything but a fully qualified ref. I don't think I've ever seen one that isn't, and the documentation is vague. It says:

  [...]The value is handled like the remote part of a refspec, and must match
  a ref which is fetched from the remote[...]

I took "match" to mean a full string match. That text comes from b888d61c83 (Make fetch a builtin, 2007-09-10); before that it said "the value has exactly to match a remote part of one of the refspecs...".

But documentation aside, if we've been allowing:
  git config branch.master.merge master

to work forever, then perhaps we need to continue to support it. I dunno.

> It means that the patch claims that remote.c::branch_merge_matches()
> assume that branch->merge[i]->src may not be a full refname by
> calling refname_match() on it, which is incorrect and may need to be
> corrected.  But that is totally outside the scope of this fix.

I make no claims. ;) I just didn't even consider a non-qualified ref to be a possibility.

The code in fetch's add_merge_config() that does branch_merge_matches() comes from 85682c1903 (Correct handling of branch.$name.merge in builtin-fetch, 2007-09-18), but I don't see any indication there that non-qualified refs were intended.

So I could either way: non-qualified refs in branch.*.merge has always worked, and we should continue to support it. Or it was never intended to work, and we are not obligated to continue supporting random things.

I do think "continue supporting" would probably just mean using expand_ref_prefix() here as you suggest. It does increase the size of our request, and the work the server has to do when it matches the prefixes (which is inherently linear on the number of prefixes we give it).

One thing we could do, but my patch doesn't, is skip sending this prefix when it is a subset of the default refspec (i.e., in the default config refs/heads/foo is already part of refs/heads/, so there is no need to specify it separately). That doesn't really help if we expand the prefix, though. The default refspec doesn't include:

  refs/remotes/refs/heads/foo/HEAD

which is exactly the kind of thing we'd ask for. Maybe that is all premature optimization, though.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 31 in “2.37.2 can't "git pull" but 2.18.0 can”
  1. Lana DeereSep 2, 2022
  2. brian m. carlsonSep 2, 2022
  3. Lana DeereSep 6, 2022
  4. Johannes SchindelinSep 7, 2022
  5. Lana DeereSep 7, 2022
  6. Jeff KingSep 8, 2022
  7. Jeff KingSep 3, 2022
  8. Lana DeereSep 6, 2022
  9. Đoàn Trần Công DanhSep 7, 2022
  10. Lana DeereSep 7, 2022
  11. Jeff KingSep 7, 2022
  12. Lana DeereSep 7, 2022
  13. Jeff KingSep 7, 2022
  14. Lana DeereSep 8, 2022
  15. Jeff KingSep 8, 2022
  16. 0/2 v2 protocol can't "git pull" with restricted refspecJeff King, Sep 8, 2022
  17. 1/2 fetch: stop checking for NULL transport->remote in do_fetch()Jeff King, Sep 8, 2022
  18. 2/2 fetch: add branch.*.merge to default ref-prefix extensionJeff King, Sep 8, 2022
  19. Junio C HamanoSep 8, 2022
  20. Junio C HamanoSep 8, 2022
  21. Jeff KingSep 9, 2022
  22. Junio C HamanoSep 9, 2022
  23. Jeff KingSep 11, 2022
  24. Lana DeereSep 9, 2022
  25. Junio C HamanoSep 9, 2022
  26. Lana DeereSep 12, 2022
  27. Jeff KingSep 13, 2022
  28. Johannes SchindelinSep 5, 2022
  29. Lana DeereSep 6, 2022
  30. Johannes SchindelinSep 7, 2022
  31. Lana DeereSep 7, 2022

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.