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

Re: Allowing "/" in the name of a git remote is a strange choice

From
Jeff King <peff@peff.net>
Date
Jul 5, 2025, 16:57 UTC
Message-ID
<20250705165750.GA1951664@coredump.intra.peff.net>
In-Reply-To
<CAHx6-Um1dq0xJ-RkW+qXe=sEa6JGViSJxjzNw56u55DHLYoT2Q@mail.gmail.com>
On Thu, Jul 03, 2025 at 09:33:20PM +0200, Per Cederqvist wrote:
Show 12 quoted lines
> > $ git fetch --all
> > Fetching origin
> > From $PRIVATE_URL
> >  + 4e31956300f...30e26ebbb19 chat/master -> origin/chat/master  (forced update)
> > Fetching origin/chat
> > From  $PRIVATE_URL
> >  + 30e26ebbb19...4e31956300f master     -> origin/chat/master  (forced update)
> 
> Every time I run "git fetch --all" git updates the origin/chat/master ref twice.
> 
> If it was up to me, I'd add a check to valid_remote_name() to ensure
> the name doesn't contain any "/" character.  I doubt it is used often.

I think the "/" here is really just a special case of a more general problem: overlapping fetch refspec destinations.

For example, try this:
  git init repo
  cd repo
  git init one
  git -C one commit --allow-empty -m foo
  git init two
  git -C two commit --allow-empty -m bar
  git config remote.one.url one
  git config remote.one.fetch +refs/heads/*:refs/remotes/collide/*
  git config remote.two.url two
  git config remote.two.fetch +refs/heads/*:refs/remotes/collide/*
  git fetch --all

which gives similar output to what you showed above. Of course it's easier to see here when the names are identical rather than one being a prefix of the other. But it's fundamentally the same issue, and forbidding "/" would not fix it.

We could perhaps detect these kinds of overlap, but I wonder:
  1. How expensive is it to do so, and when should we do it? Obviously
     for a handful of refs a quadratic approach is OK. But what if you
     had 10,000 remotes (this is not purely hypothetical; GitHub used to
     manage object migration in its fork networks with configured
     remotes, but hit enough performance issues to switch away from
     that). So I'd be hesitant to check this on every "git fetch".
  2. Is it something people actually want to do? It's certainly a
     _weird_ configuration, but I could imagine there being useful
     corner cases (e.g., one URL is an infrequently backup of the other,
     so you don't usually do "--all", or you set skipDefaultUpdate for
     one of them.

So I dunno. It feels like a configuration error in most cases, but not all. I'd probably say that people touching the config manually should be allowed to do what they want, but maybe "git remote" should be a bit more careful about names being proper subsets of existing remotes (it should already prevent the exact-match above, I'd think, because the ref namespace it uses will always match the configuration name).

-Peff
Previous: Per CederqvistNext: Jeff King
Message 8 of 18 in “Allowing "/" in the name of a git remote is a strange choice”
  1. Per CederqvistJul 3, 2025
  2. Junio C HamanoJul 4, 2025
  3. Patrick SteinhardtJul 4, 2025
  4. Lidong YanJul 4, 2025
  5. Lidong YanJul 4, 2025
  6. Junio C HamanoJul 4, 2025
  7. Per CederqvistJul 4, 2025
  8. Jeff KingJul 5, 2025
  9. remote: detect collisions in remote namesJeff King, Jul 5, 2025
  10. Patrick SteinhardtJul 7, 2025
  11. Jeff KingJul 7, 2025
  12. Junio C HamanoJul 7, 2025
  13. Jeff KingJul 8, 2025
  14. Jeff KingJul 8, 2025
  15. Junio C HamanoJul 8, 2025
  16. Jeff KingJul 9, 2025
  17. Junio C HamanoJul 7, 2025
  18. Raymond E. PascoJul 9, 2025

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.