From: Jeff King <peff@peff.net>
To: Per Cederqvist <ceder@lysator.liu.se>
Cc: git@vger.kernel.org
Subject: Re: Allowing "/" in the name of a git remote is a strange choice
Date: Sat, 5 Jul 2025 12:57:50 -0400 [thread overview]
Message-ID: <20250705165750.GA1951664@coredump.intra.peff.net> (raw)
In-Reply-To: <CAHx6-Um1dq0xJ-RkW+qXe=sEa6JGViSJxjzNw56u55DHLYoT2Q@mail.gmail.com>
On Thu, Jul 03, 2025 at 09:33:20PM +0200, Per Cederqvist wrote:
> > $ 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
next prev parent reply other threads:[~2025-07-05 16:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 19:33 Allowing "/" in the name of a git remote is a strange choice Per Cederqvist
2025-07-04 4:51 ` Junio C Hamano
2025-07-04 5:13 ` Patrick Steinhardt
2025-07-04 8:10 ` Lidong Yan
2025-07-04 8:17 ` Lidong Yan
2025-07-04 14:18 ` Junio C Hamano
2025-07-04 6:42 ` Per Cederqvist
2025-07-05 16:57 ` Jeff King [this message]
2025-07-05 18:58 ` [PATCH] remote: detect collisions in remote names Jeff King
2025-07-07 9:14 ` Patrick Steinhardt
2025-07-07 20:28 ` Jeff King
2025-07-07 21:04 ` Junio C Hamano
2025-07-08 22:59 ` Jeff King
2025-07-08 23:02 ` Jeff King
2025-07-08 23:28 ` Junio C Hamano
2025-07-09 1:21 ` Jeff King
2025-07-07 13:59 ` Junio C Hamano
2025-07-09 11:56 ` Raymond E. Pasco
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=20250705165750.GA1951664@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=ceder@lysator.liu.se \
--cc=git@vger.kernel.org \
/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).