@@ -15,8 +15,8 @@ pub mod name {
1515 StartsWithSlash ,
1616 #[ error( "Multiple slashes in a row are not allowed as they may change the reference's meaning" ) ]
1717 RepeatedSlash ,
18- #[ error( "Names must not be a single '.', but may contain it. " ) ]
19- SingleDot ,
18+ #[ error( "Path components must not start with '.'" ) ]
19+ StartsWithDot ,
2020 }
2121
2222 impl From < Infallible > for Error {
@@ -28,8 +28,8 @@ pub mod name {
2828
2929use bstr:: BStr ;
3030
31- /// Validate a reference name running all the tests in the book. This disallows lower-case references, but allows
32- /// ones like `HEAD`.
31+ /// Validate a reference name running all the tests in the book. This disallows lower-case references like `lower` , but also allows
32+ /// ones like `HEAD`, and `refs/lower` .
3333pub fn name ( path : & BStr ) -> Result < & BStr , name:: Error > {
3434 validate ( path, Mode :: Complete )
3535}
@@ -51,19 +51,17 @@ fn validate(path: &BStr, mode: Mode) -> Result<&BStr, name::Error> {
5151 return Err ( name:: Error :: StartsWithSlash ) ;
5252 }
5353 let mut previous = 0 ;
54- let mut one_before_previous = 0 ;
5554 let mut saw_slash = false ;
5655 for byte in path. iter ( ) {
5756 match * byte {
58- b'/' if previous == b'.' && one_before_previous == b'/' => return Err ( name:: Error :: SingleDot ) ,
5957 b'/' if previous == b'/' => return Err ( name:: Error :: RepeatedSlash ) ,
58+ b'.' if previous == b'/' => return Err ( name:: Error :: StartsWithDot ) ,
6059 _ => { }
6160 }
6261
6362 if * byte == b'/' {
6463 saw_slash = true ;
6564 }
66- one_before_previous = previous;
6765 previous = * byte;
6866 }
6967
0 commit comments