All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>
Subject: [PATCH 3/8] refs: move is_pseudoref_syntax() definition earlier
Date: Mon, 29 Apr 2024 04:21:48 -0400	[thread overview]
Message-ID: <20240429082148.GB233423@coredump.intra.peff.net> (raw)

We have a static local function is_pseudoref_syntax(), used by
is_pseudoref(). The difference being that the former checks only syntax,
whereas the latter actually looks at the on-disk refs.

There are a few other places in the file where we care about the
pseudoref syntax and could make use of this function. Let's move it
earlier in the file, so it can be used more extensively without having
to forward declare it.

Signed-off-by: Jeff King <peff@peff.net>
---
 refs.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/refs.c b/refs.c
index 55d2e0b2cb..d3d21ecd43 100644
--- a/refs.c
+++ b/refs.c
@@ -164,6 +164,22 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref)
 	info->ref_updated = 1;
 }
 
+static int is_pseudoref_syntax(const char *refname)
+{
+	const char *c;
+
+	for (c = refname; *c; c++) {
+		if (!isupper(*c) && *c != '-' && *c != '_')
+			return 0;
+	}
+
+	/*
+	 * HEAD is not a pseudoref, but it certainly uses the
+	 * pseudoref syntax.
+	 */
+	return 1;
+}
+
 /*
  * Try to read one refname component from the front of refname.
  * Return the length of the component found, or -1 if the component is
@@ -844,22 +860,6 @@ int is_per_worktree_ref(const char *refname)
 	       starts_with(refname, "refs/rewritten/");
 }
 
-static int is_pseudoref_syntax(const char *refname)
-{
-	const char *c;
-
-	for (c = refname; *c; c++) {
-		if (!isupper(*c) && *c != '-' && *c != '_')
-			return 0;
-	}
-
-	/*
-	 * HEAD is not a pseudoref, but it certainly uses the
-	 * pseudoref syntax.
-	 */
-	return 1;
-}
-
 int is_pseudoref(struct ref_store *refs, const char *refname)
 {
 	static const char *const irregular_pseudorefs[] = {
-- 
2.45.0.rc1.416.gbe2a76c799


                 reply	other threads:[~2024-04-29  8:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240429082148.GB233423@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.