From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Patrick Steinhardt <ps@pks.im>,
Per Cederqvist <ceder@lysator.liu.se>,
git@vger.kernel.org
Subject: Re: [PATCH] remote: detect collisions in remote names
Date: Mon, 07 Jul 2025 14:04:19 -0700 [thread overview]
Message-ID: <xmqqtt3n3e7g.fsf@gitster.g> (raw)
In-Reply-To: <20250707202801.GA3115893@coredump.intra.peff.net> (Jeff King's message of "Mon, 7 Jul 2025 16:28:01 -0400")
Jeff King <peff@peff.net> writes:
> On Mon, Jul 07, 2025 at 11:14:05AM +0200, Patrick Steinhardt wrote:
>
>> > +static int check_remote_collision(struct remote *remote, void *vname)
>>
>> Tiniest nit: I was a bit puzzled what the `v` in `vname` stands for, and
>> it took a while until I noticed that it probably stands for `void`. If
>> you end up rerolling, I'd suggest to either call this `payload` or
>> `_name`.
>
> Yeah, it's for "void". This is a pattern used elsewhere for callbacks
> (usually as "vdata", but here we didn't need a container struct since
> there's only one item). I think "payload" is not a term we usually use,
> but maybe just "data" would be the usual thing (we only need "vdata"
> when we're assigning to the non-void data type).
>
> IMHO we should probably avoid the underscore pattern. It's OK here, but
> it runs close to violating the reserved names rules (a global variable
> variable _name is bad, and _Name anywhere is bad).
"name_" is available. In fact I think it is a very common pattern
in this codebase to name an incoming parameter with trailing "_",
and assign it to a local variable with the right name and with the
right type at the top of the function.
> AFAICT "remote add" allows anything that parses as a refspec, which
> implies that refs/remotes/<name>/ passes check_refname_format(). And we
> don't allow backslashes there:
>
> $ git remote add foo/bar url
> [no output, $? is 0]
> $ git remote add 'bar\foo' url
> fatal: 'bar\foo' is not a valid remote name
>
> I don't think this is platform dependent. It's coming from the
> refname_disposition table, so we're not calling is_dir_sep(). Only '/'
> is marked in that table as end-of-component, and "\\" is forbidden.
>
> So I don't think we need to worry about backslashes here.
That agrees with my understanding. Thanks for carefully checking.
next prev parent reply other threads:[~2025-07-07 21:04 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
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 [this message]
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=xmqqtt3n3e7g.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ceder@lysator.liu.se \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
/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).