From 1260b4661c181884e2069ac9adb6189b3d6cc2f1 Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Wed, 26 Aug 2026 16:51:47 +0000 Subject: [PATCH 1/2] t1401: check symbolic-ref failure and --quiet silence on a non-symbolic ref git-symbolic-ref(1) documents that reading a name that is not a symbolic ref fails, and that --quiet does so silently. Tests such as t2020 and t5621 already rely on "symbolic-ref -q HEAD" failing on a detached HEAD, but none checks that the plain form reports the error or that --quiet stays silent. Assert that a non-symbolic ref fails with the "is not a symbolic ref" message, and that --quiet fails with no output. Use test_must_fail rather than pinning the exact exit codes, which are documented but not worth freezing in the test. Signed-off-by: Nikolaus Schuetz Signed-off-by: Junio C Hamano --- t/t1401-symbolic-ref.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh index a2a7e94716..fd3aa89a91 100755 --- a/t/t1401-symbolic-ref.sh +++ b/t/t1401-symbolic-ref.sh @@ -38,6 +38,18 @@ test_expect_success 'symbolic-ref refuses bare sha1' ' reset_to_sane +test_expect_success 'symbolic-ref reports a non-symbolic ref' ' + test_must_fail git symbolic-ref refs/heads/foo >out 2>err && + test_must_be_empty out && + test_grep "is not a symbolic ref" err +' + +test_expect_success 'symbolic-ref -q is silent on a non-symbolic ref' ' + test_must_fail git symbolic-ref -q refs/heads/foo >out 2>err && + test_must_be_empty out && + test_must_be_empty err +' + test_expect_success 'HEAD cannot be removed' ' test_must_fail git symbolic-ref -d HEAD ' From f27e711b7bd69406ce1ddc51a8239a894e6b88cc Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Thu, 20 Aug 2026 22:20:17 +0000 Subject: [PATCH 2/2] 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, open-bracket or backslash, nor the sequence "..", and cannot be the single character "@". Of these, only "?", "\" and ".." were tested embedded in an otherwise-valid refname; "*" was checked only as a lone character or with --refspec-pattern. Test all of them in that embedded form with a single loop, 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 Signed-off-by: Junio C Hamano --- t/t1402-check-ref-format.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh index cabc516ae9..9dd64662b2 100755 --- a/t/t1402-check-ref-format.sh +++ b/t/t1402-check-ref-format.sh @@ -49,16 +49,19 @@ invalid_ref 'foo/./bar' invalid_ref 'foo/bar/.' invalid_ref '.refs/foo' invalid_ref 'refs/heads/foo.' -invalid_ref 'heads/foo..bar' -invalid_ref 'heads/foo?bar' +for c in '?' '~' '^' ':' '*' '[' ' ' '\' '..' +do + invalid_ref "heads/foo${c}bar" +done 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')" invalid_ref "$(printf 'heads/foo\177')" valid_ref "$(printf 'heads/fu\303\237')"