Commit 54a6fea
committed
refs: disallow dash in root ref syntax
Our is_root_ref_syntax() function allows upper-case letters, underscore
("_") and dash ("-"). Our glossary definition was historically vague on
the allowed punctuation, but was tightened to just "upper-case
characters or underscores" in 74b50a5 (Documentation/glossary: define
root refs as refs, 2024-05-15). I don't think we have ever used a root
ref within Git with a dash, and the existing open-coded syntax check in
refname_is_safe() allows only underscores.
This logic comes from 266b182 (refs: add ref_type function,
2015-07-31), but I couldn't find any comment on the dash in the commit
message or the list discussion. It's used mostly for is_root_ref(),
which further requires that the name either end in "_HEAD" or be one of
a specific set of "irregular" root refs.
So I don't think we'd ever see a dash in the real world (you'd need to
have "FOO-BAR_HEAD"). And because of the rules in refname_is_safe(),
such a ref would not be fully functional (you couldn't delete it!).
Let's tighten this up now so that the function is consistent with (and
can be used in) other spots.
Signed-off-by: Jeff King <peff@peff.net>1 parent c68e8af commit 54a6fea
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
907 | | - | |
| 907 | + | |
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
| |||
0 commit comments