Re: [PATCH v4 1/7] refs: accept symref values in `ref_transaction[_add]_update`
- From
Jeff King <peff@peff.net>
- Date
- Apr 30, 2024, 10:33 UTC
- Message-ID
- <20240430103337.GE1279403@coredump.intra.peff.net>
- In-Reply-To
- <xmqqo79sxhug.fsf@gitster.g>
On Mon, Apr 29, 2024 at 09:18:47AM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> phillip.wood123@gmail.com writes:
>
> > ALLOW_ONELEVEL just disables the check that the refname contains a '/'
> > and I think it is aimed at checking branch and tag names without a
> > refs/{heads,tags} prefix. If we want to move away from using
> > refname_is_safe() perhaps we could add an ALLOW_PSEUDOREF flag that
> > only allows the name to contain '[A-Z_]' if there is no '/'.
>
> Makes sense.
>
> I wonder if we eventually can get rid of ALLOW_ONELEVEL, though. If
> all callers that use ALLOW_ONELEVEL know under which prefix they
> plan to hang the refname they are checking (if the refname passed
> the check), we can force the check to be performed always on the
> full refname, and it will become easier to make the check more
> consistent---as the check will have full context information.
>
> For example, with ALLOW_ONELEVEL the check may say "HEAD" is OK, but
> if we get rid of ALLOW_ONELEVEL and force the callers to always test
> the full refname, we may say "refs/heads/HEAD" is not acceptable,
> neither is "refs/tags/HEAD", but "refs/remotes/origin/HEAD" is good.One case I ran into while working on my series is refspec parsing, where we feed the left and right halves to check_refname_format(), albeit with a special flag that allows the "*" wildcard character. And there we are OK with one-level names because they will be passed through the dwim_ref() lookup.
I don't know if there are other spots that do something similar. Most of them would, I imagine, just take any input and leave it to the ref code to enforce syntax after the dwim-ref has happened.
-Peff