{"thread":{"id":"61382","subject":"[PATCH 4/8] refs: disallow dash in pseudoref syntax","startedAt":"2024-04-29T08:23:03Z","lastAt":"2024-04-29T08:23:03Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"493615","messageId":"20240429082302.GC233423@coredump.intra.peff.net","threadId":"61382","inReplyTo":null,"subject":"[PATCH 4/8] refs: disallow dash in pseudoref syntax","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-04-29T08:23:02Z","receivedAt":"2024-04-29T08:23:03Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Our is_pseudoref_syntax() function allows upper-case letters, underscore\n(\"_\") and dash (\"-\"). Our glossary definition is vague on the allowed\npunctuation, but I don't think we have ever used a pseudoref with\nanything but an underscore. And the existing open-coded syntax check in\nrefname_is_safe() allows only underscores.\n\nThe logic comes from 266b18273a (refs: add ref_type function,\n2015-07-31), but I couldn't find any comment on the dash in the commit\nmessage or the list discussion. It's used mostly for is_pseudoref(),\nwhich further requires that the name either end in \"_HEAD\" or be one of\na specific set of \"irregular\" pseudorefs.\n\nSo I don't think we'd ever see a dash in the real world (you'd need\nto have \"FOO-BAR_HEAD\"). Let's tighten this up now so that the function\nis consistent with (and can be used in) other spots.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/refs.c b/refs.c\nindex d3d21ecd43..b202dca904 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -169,7 +169,7 @@ static int is_pseudoref_syntax(const char *refname)\n \tconst char *c;\n \n \tfor (c = refname; *c; c++) {\n-\t\tif (!isupper(*c) && *c != '-' && *c != '_')\n+\t\tif (!isupper(*c) && *c != '_')\n \t\t\treturn 0;\n \t}\n \n-- \n2.45.0.rc1.416.gbe2a76c799\n\n"}]}