git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/8] refs: use is_pseudoref_syntax() in refname_is_safe()

From
Jeff King <peff@peff.net>
Date
Apr 29, 2024, 08:23 UTC
Message-ID
<20240429082320.GD233423@coredump.intra.peff.net>

The open-coded logic in refname_is_safe() predates the addition of is_pseudoref_syntax(). But now that we have it, we can make use of it. This shortens the code, but also makes sure we use a consistent definition of a pseudoref.

Note that refname_is_safe() allows HEAD, which of course is not itself a pseudoref by the strict definition (since it can be a symref). But the syntax for the two is the same, and that is all that we care about here.

Signed-off-by: Jeff King <peff@peff.net>
---
 refs.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/refs.c b/refs.c
index b202dca904..8cac7e7e59 100644
--- a/refs.c
+++ b/refs.c
@@ -362,12 +362,7 @@ int refname_is_safe(const char *refname)
 		return result;
 	}
 
-	do {
-		if (!isupper(*refname) && *refname != '_')
-			return 0;
-		refname++;
-	} while (*refname);
-	return 1;
+	return is_pseudoref_syntax(refname);
 }
 
 /*
-- 
2.45.0.rc1.416.gbe2a76c799
Message 1 of 1 in “refs: use is_pseudoref_syntax() in refname_is_safe()”
  1. 5/8 refs: use is_pseudoref_syntax() in refname_is_safe()Jeff King, Apr 29, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.