Merge branch 'ns/ref-symref-additional-tests' into seen

A few tests for the reference handling subsystem have been added to
exercise the handling of forbidden characters and symbolic references.

* ns/ref-symref-additional-tests:
  t1402: test forbidden characters in refnames
  t1401: check symbolic-ref failure and --quiet silence on a non-symbolic ref
seen
Junio C Hamano 2026-08-31 13:53:29 -07:00
commit 7ed11315af
2 changed files with 18 additions and 3 deletions

View File

@ -38,6 +38,18 @@ test_expect_success 'symbolic-ref refuses bare sha1' '


reset_to_sane 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_expect_success 'HEAD cannot be removed' '
test_must_fail git symbolic-ref -d HEAD test_must_fail git symbolic-ref -d HEAD
' '

View File

@ -49,16 +49,19 @@ invalid_ref 'foo/./bar'
invalid_ref 'foo/bar/.' invalid_ref 'foo/bar/.'
invalid_ref '.refs/foo' invalid_ref '.refs/foo'
invalid_ref 'refs/heads/foo.' invalid_ref 'refs/heads/foo.'
invalid_ref 'heads/foo..bar' for c in '?' '~' '^' ':' '*' '[' ' ' '\' '..'
invalid_ref 'heads/foo?bar' do
invalid_ref "heads/foo${c}bar"
done
valid_ref 'foo./bar' valid_ref 'foo./bar'
invalid_ref 'heads/foo.lock' invalid_ref 'heads/foo.lock'
invalid_ref 'heads///foo.lock' invalid_ref 'heads///foo.lock'
invalid_ref 'foo.lock/bar' invalid_ref 'foo.lock/bar'
invalid_ref 'foo.lock///bar' invalid_ref 'foo.lock///bar'
valid_ref 'heads/foo@bar' valid_ref 'heads/foo@bar'
valid_ref 'refs/@'
invalid_ref '@' --allow-onelevel
invalid_ref 'heads/v@{ation' invalid_ref 'heads/v@{ation'
invalid_ref 'heads/foo\bar'
invalid_ref "$(printf 'heads/foo\t')" invalid_ref "$(printf 'heads/foo\t')"
invalid_ref "$(printf 'heads/foo\177')" invalid_ref "$(printf 'heads/foo\177')"
valid_ref "$(printf 'heads/fu\303\237')" valid_ref "$(printf 'heads/fu\303\237')"