{"thread":{"id":"61383","subject":"[PATCH 5/8] refs: use is_pseudoref_syntax() in refname_is_safe()","startedAt":"2024-04-29T08:23:21Z","lastAt":"2024-04-29T08:23:21Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"493616","messageId":"20240429082320.GD233423@coredump.intra.peff.net","threadId":"61383","inReplyTo":null,"subject":"[PATCH 5/8] refs: use is_pseudoref_syntax() in refname_is_safe()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-04-29T08:23:20Z","receivedAt":"2024-04-29T08:23:21Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The open-coded logic in refname_is_safe() predates the addition of\nis_pseudoref_syntax(). But now that we have it, we can make use of it.\nThis shortens the code, but also makes sure we use a consistent\ndefinition of a pseudoref.\n\nNote that refname_is_safe() allows HEAD, which of course is not itself a\npseudoref by the strict definition (since it can be a symref). But the\nsyntax for the two is the same, and that is all that we care about here.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs.c | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex b202dca904..8cac7e7e59 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -362,12 +362,7 @@ int refname_is_safe(const char *refname)\n \t\treturn result;\n \t}\n \n-\tdo {\n-\t\tif (!isupper(*refname) && *refname != '_')\n-\t\t\treturn 0;\n-\t\trefname++;\n-\t} while (*refname);\n-\treturn 1;\n+\treturn is_pseudoref_syntax(refname);\n }\n \n /*\n-- \n2.45.0.rc1.416.gbe2a76c799\n\n"}]}