Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>
Subject: [PATCH 4/8] refs: disallow dash in pseudoref syntax
Date: Mon, 29 Apr 2024 04:23:02 -0400	[thread overview]
Message-ID: <20240429082302.GC233423@coredump.intra.peff.net> (raw)

Our is_pseudoref_syntax() function allows upper-case letters, underscore
("_") and dash ("-"). Our glossary definition is vague on the allowed
punctuation, but I don't think we have ever used a pseudoref with
anything but an underscore. And the existing open-coded syntax check in
refname_is_safe() allows only underscores.

The logic comes from 266b18273a (refs: add ref_type function,
2015-07-31), but I couldn't find any comment on the dash in the commit
message or the list discussion. It's used mostly for is_pseudoref(),
which further requires that the name either end in "_HEAD" or be one of
a specific set of "irregular" pseudorefs.

So I don't think we'd ever see a dash in the real world (you'd need
to have "FOO-BAR_HEAD"). Let's tighten this up now so that the function
is consistent with (and can be used in) other spots.

Signed-off-by: Jeff King <peff@peff.net>
---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/refs.c b/refs.c
index d3d21ecd43..b202dca904 100644
--- a/refs.c
+++ b/refs.c
@@ -169,7 +169,7 @@ static int is_pseudoref_syntax(const char *refname)
 	const char *c;
 
 	for (c = refname; *c; c++) {
-		if (!isupper(*c) && *c != '-' && *c != '_')
+		if (!isupper(*c) && *c != '_')
 			return 0;
 	}
 
-- 
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=20240429082302.GC233423@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).