code: func (p *Parser) checkRefFormat(token token, literal string, previousToken token, buffer string, endOfRef bool) error {
  	switch token {
  	case aslash, space, control, qmark, asterisk, obracket:
  		return &ErrInvalidRevision{fmt.Sprintf(`must not contains "%s"`, literal)}
  	}
  
  	switch {
  	case (token == dot || token == slash) && buffer == "":
  		return &ErrInvalidRevision{fmt.Sprintf(`must not start with "%s"`, literal)}
  	case previousToken == slash && endOfRef:
  		return &ErrInvalidRevision{`must not end with "/"`}
  	case previousToken == dot && endOfRef:
  		return &ErrInvalidRevision{`must not end with "."`}
  	case token == dot && previousToken == slash:
  		return &ErrInvalidRevision{`must not contains "/."`}
  	case previousToken == dot && token == dot:
  		return &ErrInvalidRevision{`must not contains ".."`}
  	case previousToken == slash && token == slash:
  		return &ErrInvalidRevision{`must not contains consecutively "/"`}
  	case (token == slash || endOfRef) && len(buffer) > 4 && buffer[len(buffer)-5:] == ".lock":
  		return &ErrInvalidRevision{"cannot end with .lock"}
  	}
  
  	return nil
  }
docs: // checkRefFormat ensure reference name follow rules defined here :
  // https://git-scm.com/docs/git-check-ref-format