Disallow '\' in ref names
This is asking for trouble since '\' is a directory separator in Windows and thus may produce unpredictable results. Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Robin Rosenberg committed
May 8, 2009 at 07:32 UTC
a4c2e69936df8dd0b071b85664c6cc6a4870dd84
2 files changed
+4
-1
Documentation/git-check-ref-format.txt
+2
@@ -38,6 +38,8 @@ imposes the following rules on how references are named:
38
39
. They cannot contain a sequence `@{`.
40
41
+- They cannot contain a `\\`.
42
+
43
These rules make it easy for shell script based tools to parse
44
reference names, pathname expansion by the shell when a reference name is used
45
unquoted (by mistake), and also avoids ambiguities in certain
refs.c
+2
-1
@@ -682,12 +682,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
682
* - it has ASCII control character, "~", "^", ":" or SP, anywhere, or
683
* - it ends with a "/".
684
* - it ends with ".lock"
685
+ * - it contains a "\" (backslash)
686
*/
687
688
static inline int bad_ref_char(int ch)
689
{
690
if (((unsigned) ch) <= ' ' ||
690
- ch == '~' || ch == '^' || ch == ':')
691
+ ch == '~' || ch == '^' || ch == ':' || ch == '\\')
692
return 1;
693
/* 2.13 Pattern Matching Notation */
694
if (ch == '?' || ch == '[') /* Unsupported */