6 "github.com/git-lfs/git-lfs/tools"
9 type pktlineReader struct {
15 var _ io.Reader = new(pktlineReader)
17 func (r *pktlineReader) Read(p []byte) (int, error) {
21 // If there is data in the buffer, shift as much out of it and
22 // into the given "p" as we can.
23 n = tools.MinInt(len(p), len(r.buf))
29 // Loop and grab as many packets as we can in a given "run", until we
30 // have either, a) overfilled the given buffer "p", or we have started
31 // to internally buffer in "r.buf".
33 chunk, err := r.pl.readPacket()
39 // If we got an empty chunk, then we know that we have
40 // reached the end of processing for this particular
41 // packet, so let's terminate.
46 // Figure out how much of the packet we can read into "p".
47 nn := tools.MinInt(len(chunk), len(p[n:]))
49 // Move that amount into "p", from where we left off.
50 copy(p[n:], chunk[:nn])
51 // And move the rest into the buffer.
52 r.buf = append(r.buf, chunk[nn:]...)
54 // Mark that we have read "nn" bytes into "p"