From f254db5b0988762079bf95791c7807e100852156 Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Thu, 13 Aug 2026 02:07:30 -0400 Subject: [PATCH] t1402: test forbidden characters in refnames git-check-ref-format(1) documents that a refname cannot contain a space, tilde, caret, colon, question-mark, asterisk or open-bracket, and that it cannot be the single character "@". Of these, only "?" was tested as a character embedded in an otherwise-valid refname; "*" was checked only as a lone character or with --refspec-pattern. Add the remaining forbidden characters in that embedded form, and check that "@" alone is rejected even with --allow-onelevel -- where "@" is otherwise a valid refname component, as "refs/@" confirms. Signed-off-by: Nikolaus Schuetz --- t/t1402-check-ref-format.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh index cabc516ae9a4fa..bc1e878a0fb4a1 100755 --- a/t/t1402-check-ref-format.sh +++ b/t/t1402-check-ref-format.sh @@ -51,12 +51,20 @@ invalid_ref '.refs/foo' invalid_ref 'refs/heads/foo.' invalid_ref 'heads/foo..bar' invalid_ref 'heads/foo?bar' +invalid_ref 'heads/foo~bar' +invalid_ref 'heads/foo^bar' +invalid_ref 'heads/foo:bar' +invalid_ref 'heads/foo*bar' +invalid_ref 'heads/foo[bar' +invalid_ref 'heads/foo bar' valid_ref 'foo./bar' invalid_ref 'heads/foo.lock' invalid_ref 'heads///foo.lock' invalid_ref 'foo.lock/bar' invalid_ref 'foo.lock///bar' valid_ref 'heads/foo@bar' +valid_ref 'refs/@' +invalid_ref '@' --allow-onelevel invalid_ref 'heads/v@{ation' invalid_ref 'heads/foo\bar' invalid_ref "$(printf 'heads/foo\t')"