Forbid DEL characters in reference names

DEL is an ASCII control character and therefore should not be permitted in reference names. Add tests for this and other unusual characters. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Aug 27, 2011 at 06:12 UTC f3738c1ce9193a4bf45ba1a3ea67d0cf32da0257
2 files changed +4 -1
refs.c
+1 -1
@@ -837,7 +837,7 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
837
838 static inline int bad_ref_char(int ch)
839 {
840 - if (((unsigned) ch) <= ' ' ||
840 + if (((unsigned) ch) <= ' ' || ch == 0x7f ||
841 ch == '~' || ch == '^' || ch == ':' || ch == '\\')
842 return 1;
843 /* 2.13 Pattern Matching Notation */
t/t1402-check-ref-format.sh
+3
@@ -30,6 +30,9 @@ invalid_ref 'heads/foo.lock'
30 valid_ref 'heads/foo@bar'
31 invalid_ref 'heads/v@{ation'
32 invalid_ref 'heads/foo\bar'
33 +invalid_ref "$(printf 'heads/foo\t')"
34 +invalid_ref "$(printf 'heads/foo\177')"
35 +valid_ref "$(printf 'heads/fu\303\237')"
36
37 test_expect_success "check-ref-format --branch @{-1}" '
38 T=$(git write-tree) &&