Skip to content

Commit a4c2e69

Browse files
robinrosenberggitster
authored andcommitted
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>
1 parent f01f109 commit a4c2e69

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Documentation/git-check-ref-format.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ imposes the following rules on how references are named:
3838

3939
. They cannot contain a sequence `@{`.
4040

41+
- They cannot contain a `\\`.
42+
4143
These rules make it easy for shell script based tools to parse
4244
reference names, pathname expansion by the shell when a reference name is used
4345
unquoted (by mistake), and also avoids ambiguities in certain

refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
682682
* - it has ASCII control character, "~", "^", ":" or SP, anywhere, or
683683
* - it ends with a "/".
684684
* - it ends with ".lock"
685+
* - it contains a "\" (backslash)
685686
*/
686687

687688
static inline int bad_ref_char(int ch)
688689
{
689690
if (((unsigned) ch) <= ' ' ||
690-
ch == '~' || ch == '^' || ch == ':')
691+
ch == '~' || ch == '^' || ch == ':' || ch == '\\')
691692
return 1;
692693
/* 2.13 Pattern Matching Notation */
693694
if (ch == '?' || ch == '[') /* Unsupported */

0 commit comments

Comments
 (0)