diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-09-12 20:14:37 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-09-12 20:16:06 +0300 |
commit | 7a1469bee0d149277dd41b619486d1af18b49dd8 (patch) | |
tree | 5a4fe77bbc8673a650a21efd6a2b4166620f506b /internal/diff | |
parent | 17a178a8e92a64df10a47efc21fe2d379c9720e2 (diff) |
Fix diff parsing when the last 10 bytes of a stream contain newlines
Diffstat (limited to 'internal/diff')
-rw-r--r-- | internal/diff/diff.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/diff/diff.go b/internal/diff/diff.go index 9fcc013e9..ef5aca2bd 100644 --- a/internal/diff/diff.go +++ b/internal/diff/diff.go @@ -325,7 +325,15 @@ func parseRawLine(line []byte, diff *Diff) error { } func (parser *Parser) consumeChunkLine() { - line, err := parser.patchReader.ReadBytes('\n') + var line []byte + var err error + + if parser.finished { + line, err = ioutil.ReadAll(parser.patchReader) + } else { + line, err = parser.patchReader.ReadBytes('\n') + } + if err != nil && err != io.EOF { parser.err = fmt.Errorf("read chunk line: %v", err) return |