File tree 2 files changed +7
-7
lines changed 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ import (
11
11
"strings"
12
12
)
13
13
14
- const (
15
- nullChar = "\x00 "
16
- dualNullChar = "\x00 \x00 "
14
+ var (
15
+ nullChar = [] byte ( "\x00 " )
16
+ dualNullChar = [] byte ( "\x00 \x00 " )
17
17
)
18
18
19
19
// Format supports specifying and parsing an output format for 'git
@@ -26,12 +26,12 @@ type Format struct {
26
26
// fieldDelim is the character sequence that is used to separate fields
27
27
// for each reference. fieldDelim and refDelim should be selected to not
28
28
// interfere with each other and to not be present in field values.
29
- fieldDelim string
29
+ fieldDelim [] byte
30
30
// refDelim is the character sequence used to separate reference from
31
31
// each other in the output. fieldDelim and refDelim should be selected
32
32
// to not interfere with each other and to not be present in field
33
33
// values.
34
- refDelim string
34
+ refDelim [] byte
35
35
}
36
36
37
37
// NewFormat creates a forEachRefFormat using the specified fieldNames. See
@@ -70,7 +70,7 @@ func (f Format) Parser(r io.Reader) *Parser {
70
70
71
71
// hexEscaped produces hex-escpaed characters from a string. For example, "\n\0"
72
72
// would turn into "%0a%00".
73
- func (f Format ) hexEscaped (delim string ) string {
73
+ func (f Format ) hexEscaped (delim [] byte ) string {
74
74
escaped := ""
75
75
for i := 0 ; i < len (delim ); i ++ {
76
76
escaped += "%" + hex .EncodeToString ([]byte {delim [i ]})
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ func (p *Parser) parseRef(refBlock string) (map[string]string, error) {
93
93
94
94
fieldValues := make (map [string ]string )
95
95
96
- fields := strings .Split (refBlock , p .format .fieldDelim )
96
+ fields := strings .Split (refBlock , string ( p .format .fieldDelim ) )
97
97
if len (fields ) != len (p .format .fieldNames ) {
98
98
return nil , fmt .Errorf ("unexpected number of reference fields: wanted %d, was %d" ,
99
99
len (fields ), len (p .format .fieldNames ))
You can’t perform that action at this time.
0 commit comments