···166166// the line at limit and the line number. If the error is nil or io.EOF, the
167167// line number equals limit. A negative limit checks that the source has no
168168// more lines to read.
169169-func copyLines(dst io.Writer, src LineReader, limit int64) (string, int, error) {
170170- // TODO(bkeyes): fix int vs int64 for limit and return value
169169+func copyLines(dst io.Writer, src LineReader, limit int64) (string, int64, error) {
171170 for {
172171 line, n, err := src.ReadLine()
173172 switch {
174173 case limit < 0 && err == io.EOF && line == "":
175175- return "", int(limit), nil
176176- case int64(n) == limit:
174174+ return "", limit, nil
175175+ case n == limit:
177176 return line, n, err
178178- case int64(n) > limit:
177177+ case n > limit:
179178 if limit < 0 {
180179 return "", n, conflictError("cannot create new file from non-empty src")
181180 }
+4-5
gitdiff/io.go
···3535// numbers may be incorrect if calls to ReadLine are mixed with calls to other
3636// read methods.
3737type LineReader interface {
3838- // TODO(bkeyes): consider making lineno int64 to match fragment types
3939- ReadLine() (string, int, error)
3838+ ReadLine() (string, int64, error)
4039}
41404241// NewLineReader returns a LineReader starting at a specific line and using the
4342// newline character, \n, as a line separator. If r is a StringReader, it is
4443// used directly. Otherwise, it is wrapped in a way that may read extra data
4544// from the underlying input.
4646-func NewLineReader(r io.Reader, lineno int) LineReader {
4545+func NewLineReader(r io.Reader, lineno int64) LineReader {
4746 sr, ok := r.(readStringReader)
4847 if !ok {
4948 sr = bufio.NewReader(r)
···53525453type lineReader struct {
5554 r readStringReader
5656- n int
5555+ n int64
5756}
58575959-func (lr *lineReader) ReadLine() (line string, lineno int, err error) {
5858+func (lr *lineReader) ReadLine() (line string, lineno int64, err error) {
6059 lineno = lr.n
6160 line, err = lr.r.ReadString('\n')
6261 if err == nil {
+1-1
gitdiff/io_test.go
···3434 if d != line.Data {
3535 t.Errorf("incorrect line data: expected %q, actual %q", line.Data, d)
3636 }
3737- if n != i {
3737+ if n != int64(i) {
3838 t.Errorf("incorrect line number: expected %d, actual %d", i, n)
3939 }
4040 }