Re: [PATCH 4/4] remote: check branch names
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 12, 2024, 16:32 UTC
- Message-ID
- <xmqqjzfg4yv1.fsf@gitster.g>
- In-Reply-To
- <ZuK80YvPSo8WUpp2@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> Agreed. It's also kind of curious that the function lives in > "object-name.c" and not in "refs.c".
Because the helper groks things like "-" (aka "@{-1}"), it does a bit more than "is this a reasonable name for a ref" and "please give me the current value of this ref". Also "refs/remotes/origin/HEAD" may be valid as a refname, but forbidding "refs/heads/HEAD" is done conceptually one level closer to the end-users. Eventually, I think it should move next to branch.c:validate_branchname() as a common helper between "git branch" and "git remote" (possibly also with "git switch/checkout", if they need to do validation themselves, but I suspect they just call into branch.c at a bit higher "here is a name, create it and you are free to complain---I do not care about the details of why you decide the name is bad" interface).
Thanks.