splitDiffLines splits unified diff text on "\n" and drops the carriage return that CRLF-terminated diff text leaves at the end of every line. Git writes its own structural lines with "\n", but the diff text can reach us already converted: a .patch checked out under core.autocrlf=true, or output cap
(text string)
| 40 | // carriage return: resolver.go trims it before matching lines, and filereader |
| 41 | // and viewer do the same when reading file content. |
| 42 | func splitDiffLines(text string) []string { |
| 43 | lines := strings.Split(text, "\n") |
| 44 | for i, line := range lines { |
| 45 | lines[i] = strings.TrimSuffix(line, "\r") |
| 46 | } |
| 47 | return lines |
| 48 | } |
| 49 | |
| 50 | // parseDiffHeaderLine extracts the two pathnames from a "diff --git" line, |
| 51 | // preferring the split a bare header names twice and falling back to |
no outgoing calls