From 36db9e213f9cc983cbee99c3cd518e92a938634e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Thu, 25 Jan 2018 09:53:07 +0100 Subject: [PATCH] compile error --- models/git_diff.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/git_diff.go b/models/git_diff.go index ad81791e0..0a7a23c25 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -256,10 +256,10 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D var linebuf bytes.Buffer for { peek, err := input.Peek(maxLineCharacters) - if err != bufio.ErrBufferFull { + if err != nil && err != bufio.ErrBufferFull { return nil, fmt.Errorf("PeekByte: %v", err) } - newLine := bytes.Index(peek, []byte("\n")); + newLine := bytes.IndexByte(peek, '\n'); if newLine == -1 { // Instead of reading things, and copying memory around, // we simply discard them (which doesn't allocate memory) @@ -272,7 +272,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D if curFile.IsIncomplete { // Since we get here without hiting the above case, we've found a newline // and only discard that part. - input.Discard(newFile) + input.Discard(newLine) break } buff := make([]byte, newLine) @@ -287,7 +287,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D if n != newLine { return nil, fmt.Errorf("Read: could not read enough bytes %d != %d", n, newLine) } - n, err := linebuf.Write(buff) + n, err = linebuf.Write(buff) if err != nil { return nil, fmt.Errorf("Write: %v", err) }