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 5/8] refs: use is_pseudoref_syntax() in refname_is_safe()
Date: Mon, 29 Apr 2024 04:23:20 -0400	[thread overview]
Message-ID: <20240429082320.GD233423@coredump.intra.peff.net> (raw)

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


                 reply	other threads:[~2024-04-29  8:23 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=20240429082320.GD233423@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.