{"thread":{"id":"61381","subject":"[PATCH 3/8] refs: move is_pseudoref_syntax() definition earlier","startedAt":"2024-04-29T08:21:49Z","lastAt":"2024-04-29T08:21:49Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"493614","messageId":"20240429082148.GB233423@coredump.intra.peff.net","threadId":"61381","inReplyTo":null,"subject":"[PATCH 3/8] refs: move is_pseudoref_syntax() definition earlier","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-04-29T08:21:48Z","receivedAt":"2024-04-29T08:21:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We have a static local function is_pseudoref_syntax(), used by\nis_pseudoref(). The difference being that the former checks only syntax,\nwhereas the latter actually looks at the on-disk refs.\n\nThere are a few other places in the file where we care about the\npseudoref syntax and could make use of this function. Let's move it\nearlier in the file, so it can be used more extensively without having\nto forward declare it.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n refs.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 55d2e0b2cb..d3d21ecd43 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -164,6 +164,22 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref)\n \tinfo->ref_updated = 1;\n }\n \n+static int is_pseudoref_syntax(const char *refname)\n+{\n+\tconst char *c;\n+\n+\tfor (c = refname; *c; c++) {\n+\t\tif (!isupper(*c) && *c != '-' && *c != '_')\n+\t\t\treturn 0;\n+\t}\n+\n+\t/*\n+\t * HEAD is not a pseudoref, but it certainly uses the\n+\t * pseudoref syntax.\n+\t */\n+\treturn 1;\n+}\n+\n /*\n  * Try to read one refname component from the front of refname.\n  * Return the length of the component found, or -1 if the component is\n@@ -844,22 +860,6 @@ int is_per_worktree_ref(const char *refname)\n \t       starts_with(refname, \"refs/rewritten/\");\n }\n \n-static int is_pseudoref_syntax(const char *refname)\n-{\n-\tconst char *c;\n-\n-\tfor (c = refname; *c; c++) {\n-\t\tif (!isupper(*c) && *c != '-' && *c != '_')\n-\t\t\treturn 0;\n-\t}\n-\n-\t/*\n-\t * HEAD is not a pseudoref, but it certainly uses the\n-\t * pseudoref syntax.\n-\t */\n-\treturn 1;\n-}\n-\n int is_pseudoref(struct ref_store *refs, const char *refname)\n {\n \tstatic const char *const irregular_pseudorefs[] = {\n-- \n2.45.0.rc1.416.gbe2a76c799\n\n"}]}