* [PATCH 4/8] refs: disallow dash in pseudoref syntax
@ 2024-04-29 8:23 Jeff King
0 siblings, 0 replies; only message in thread
From: Jeff King @ 2024-04-29 8:23 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt
Our is_pseudoref_syntax() function allows upper-case letters, underscore
("_") and dash ("-"). Our glossary definition is vague on the allowed
punctuation, but I don't think we have ever used a pseudoref with
anything but an underscore. And the existing open-coded syntax check in
refname_is_safe() allows only underscores.
The logic comes from 266b18273a (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_pseudoref(),
which further requires that the name either end in "_HEAD" or be one of
a specific set of "irregular" pseudorefs.
So I don't think we'd ever see a dash in the real world (you'd need
to have "FOO-BAR_HEAD"). 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>
---
refs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index d3d21ecd43..b202dca904 100644
--- a/refs.c
+++ b/refs.c
@@ -169,7 +169,7 @@ static int is_pseudoref_syntax(const char *refname)
const char *c;
for (c = refname; *c; c++) {
- if (!isupper(*c) && *c != '-' && *c != '_')
+ if (!isupper(*c) && *c != '_')
return 0;
}
--
2.45.0.rc1.416.gbe2a76c799
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-29 8:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 8:23 [PATCH 4/8] refs: disallow dash in pseudoref syntax Jeff King
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).