Commit
1260b4661c181884e2069ac9adb6189b3d6cc2f1
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 <nikolauspschuetz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nikolaus Schuetz <nikolauspschuetz@gmail.com> · 2026-08-26 16:51 UTC · committed by Junio C Hamano
1 file changed,
+12
−0
modified t/t1401-symbolic-ref.sh
| @@ -38,6 +38,18 @@ test_expect_success 'symbolic-ref refuses bare sha1' ' | |||
| 38 | 38 | ||
| 39 | 39 | reset_to_sane | |
| 40 | 40 | ||
| 41 | + | test_expect_success 'symbolic-ref reports a non-symbolic ref' ' | |
| 42 | + | test_must_fail git symbolic-ref refs/heads/foo >out 2>err && | |
| 43 | + | test_must_be_empty out && | |
| 44 | + | test_grep "is not a symbolic ref" err | |
| 45 | + | ' | |
| 46 | + | ||
| 47 | + | test_expect_success 'symbolic-ref -q is silent on a non-symbolic ref' ' | |
| 48 | + | test_must_fail git symbolic-ref -q refs/heads/foo >out 2>err && | |
| 49 | + | test_must_be_empty out && | |
| 50 | + | test_must_be_empty err | |
| 51 | + | ' | |
| 52 | + | ||
| 41 | 53 | test_expect_success 'HEAD cannot be removed' ' | |
| 42 | 54 | test_must_fail git symbolic-ref -d HEAD | |
| 43 | 55 | ' | |