Skip to content

Commit e05aae6

Browse files
committed
Merge branch 'rr/forbid-bs-in-ref'
* rr/forbid-bs-in-ref: Disallow '\' in ref names
2 parents 5eb3d94 + a4c2e69 commit e05aae6

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
@@ -42,6 +42,8 @@ imposes the following rules on how references are named:
4242

4343
. They cannot contain a sequence `@{`.
4444

45+
- They cannot contain a `\\`.
46+
4547
These rules make it easy for shell script based tools to parse
4648
reference names, pathname expansion by the shell when a reference name is used
4749
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)