func ScanDiffs(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	k, newLineIndex := 0, 0
	dataLen := len(data) - 1
	for k < dataLen {
		i := bytes.IndexByte(data[k:], '\n')
		if i < 0 {
			k = dataLen
			continue
		}
		newLineIndex = k + i + 1
		if beginsWithHash(string(data[newLineIndex:])) {
			return newLineIndex, dropCR(data[0 : newLineIndex-1]), nil
		}
		if isDiffHeader(&data, newLineIndex) {
			prevLineIndex := getPreviousLineIndex(data, newLineIndex-1)
			if !beginsWithHash(string(data[prevLineIndex : k+i])) {
				return newLineIndex, dropCR(data[0 : newLineIndex-1]), nil
			}
		}
		k += i + 1
	}
	if atEOF {
		return len(data), dropCR(data), nil
	}
	return 0, nil, nil
}
ScanDiffs splits on the diff of an inidividual file
package git
import "bytes"
const (
	diffSep = "diff --git a"
)
func isDiffHeader(data *[]byte, index int) bool {
	diffSepLen := len(diffSep)
	diffSepEndIndex := index + diffSepLen
	dataLen := len(*data) - 1
	return diffSepEndIndex < dataLen && string((*data)[index:diffSepEndIndex]) == diffSep
}
func getPreviousLineIndex(data []byte, index int) int {
	i := bytes.LastIndex((data)[0:index], []byte("\n"))
	if i < 0 {
		return 0
	}
	return i
}