Skip to content

Commit 0586387

Browse files
committed
fix bug with file names being terminated by a tab
1 parent 5b2cb82 commit 0586387

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

diff/parse.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,12 @@ func (r *FileDiffReader) readOneFileHeader(prefix []byte) (filename string, time
246246
r.line++
247247
line = line[len(prefix):]
248248

249-
parts := bytes.SplitN(line, []byte("\t"), 2)
250-
filename = string(parts[0])
249+
trimmedLine := strings.TrimSpace(string(line)) // filenames that contain spaces may be terminated by a tab
250+
parts := strings.SplitN(trimmedLine, "\t", 2)
251+
filename = parts[0]
251252
if len(parts) == 2 {
252253
// Timestamp is optional, but this header has it.
253-
ts, err := time.Parse(diffTimeFormat, string(parts[1]))
254+
ts, err := time.Parse(diffTimeFormat, parts[1])
254255
if err != nil {
255256
return "", nil, err
256257
}

0 commit comments

Comments
 (0)