fork of go-gitdiff with jj support
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Standardize on int64 for line numbers

This matches the type used for positions in text fragments.

+9 -11
+4 -5
gitdiff/apply.go
··· 166 166 // the line at limit and the line number. If the error is nil or io.EOF, the 167 167 // line number equals limit. A negative limit checks that the source has no 168 168 // more lines to read. 169 - func copyLines(dst io.Writer, src LineReader, limit int64) (string, int, error) { 170 - // TODO(bkeyes): fix int vs int64 for limit and return value 169 + func copyLines(dst io.Writer, src LineReader, limit int64) (string, int64, error) { 171 170 for { 172 171 line, n, err := src.ReadLine() 173 172 switch { 174 173 case limit < 0 && err == io.EOF && line == "": 175 - return "", int(limit), nil 176 - case int64(n) == limit: 174 + return "", limit, nil 175 + case n == limit: 177 176 return line, n, err 178 - case int64(n) > limit: 177 + case n > limit: 179 178 if limit < 0 { 180 179 return "", n, conflictError("cannot create new file from non-empty src") 181 180 }
+4 -5
gitdiff/io.go
··· 35 35 // numbers may be incorrect if calls to ReadLine are mixed with calls to other 36 36 // read methods. 37 37 type LineReader interface { 38 - // TODO(bkeyes): consider making lineno int64 to match fragment types 39 - ReadLine() (string, int, error) 38 + ReadLine() (string, int64, error) 40 39 } 41 40 42 41 // NewLineReader returns a LineReader starting at a specific line and using the 43 42 // newline character, \n, as a line separator. If r is a StringReader, it is 44 43 // used directly. Otherwise, it is wrapped in a way that may read extra data 45 44 // from the underlying input. 46 - func NewLineReader(r io.Reader, lineno int) LineReader { 45 + func NewLineReader(r io.Reader, lineno int64) LineReader { 47 46 sr, ok := r.(readStringReader) 48 47 if !ok { 49 48 sr = bufio.NewReader(r) ··· 53 52 54 53 type lineReader struct { 55 54 r readStringReader 56 - n int 55 + n int64 57 56 } 58 57 59 - func (lr *lineReader) ReadLine() (line string, lineno int, err error) { 58 + func (lr *lineReader) ReadLine() (line string, lineno int64, err error) { 60 59 lineno = lr.n 61 60 line, err = lr.r.ReadString('\n') 62 61 if err == nil {
+1 -1
gitdiff/io_test.go
··· 34 34 if d != line.Data { 35 35 t.Errorf("incorrect line data: expected %q, actual %q", line.Data, d) 36 36 } 37 - if n != i { 37 + if n != int64(i) { 38 38 t.Errorf("incorrect line number: expected %d, actual %d", i, n) 39 39 } 40 40 }