MCPcopy Create free account
hub / github.com/alibaba/open-code-review / splitDiffLines

Function splitDiffLines

internal/diff/parser.go:42–48  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

40// carriage return: resolver.go trims it before matching lines, and filereader
41// and viewer do the same when reading file content.
42func 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

Callers 3

ParsePatchFunction · 0.85
ParseHunksFunction · 0.85

Calls

no outgoing calls

Tested by 1