@matheusbsbs / matheus-bagliano / commits / 68283999f8
Fork 0

Forbid pattern maching characters in refnames.

by marking '?', '*', and '[' as bad_ref_char(). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 15, 2005 at 18:03 UTC 68283999f8ae0e9286f8b7f199905b77d608cb80
2 files changed +8 -4
Documentation/git-check-ref-format.txt
+5 -3
@@ -26,13 +26,15 @@ imposes the following rules on how refs are named:
26
27 . It cannot have ASCII control character (i.e. bytes whose
28 values are lower than \040, or \177 `DEL`), space, tilde `~`,
29 - caret `{caret}`, or colon `:` anywhere;
29 + caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
30 + or open bracket `[` anywhere;
31
32 . It cannot end with a slash `/`.
33
34 These rules makes it easy for shell script based tools to parse
34 -refnames, and also avoids ambiguities in certain refname
35 -expressions (see gitlink:git-rev-parse[1]). Namely:
35 +refnames, pathname expansion by the shell when a refname is used
36 +unquoted (by mistake), and also avoids ambiguities in certain
37 +refname expressions (see gitlink:git-rev-parse[1]). Namely:
38
39 . double-dot `..` are often used as in `ref1..ref2`, and in some
40 context this notation means `{caret}ref1 ref2` (i.e. not in
refs.c
+3 -1
@@ -313,7 +313,9 @@ int write_ref_sha1(const char *ref, int fd, const unsigned char *sha1)
313 static inline int bad_ref_char(int ch)
314 {
315 return (((unsigned) ch) <= ' ' ||
316 - ch == '~' || ch == '^' || ch == ':');
316 + ch == '~' || ch == '^' || ch == ':' ||
317 + /* 2.13 Pattern Matching Notation */
318 + ch == '?' || ch == '*' || ch == '[');
319 }
320
321 int check_ref_format(const char *ref)