From 0391dcceef87c1b1d7b18dc834e9a3e38ac9dfad Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Mon, 24 Aug 2026 18:10:28 -0500 Subject: [PATCH] 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 --- 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 a2a7e947164c2a..fd3aa89a91cbc0 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 '