MCPcopy Create free account
hub / github.com/go-git/go-git / processEqualsLines

Method processEqualsLines

plumbing/format/diff/unified_encoder.go:280–302  ·  view source on GitHub ↗
(ls []string, i int)

Source from the content-addressed store, hash-verified

278}
279
280func (g *hunksGenerator) processEqualsLines(ls []string, i int) {
281 if g.current == nil {
282 g.beforeContext = append(g.beforeContext, ls...)
283 return
284 }
285
286 g.afterContext = append(g.afterContext, ls...)
287 if len(g.afterContext) <= g.ctxLines*2 && i != len(g.chunks)-1 {
288 g.current.AddOp(Equal, g.afterContext...)
289 g.afterContext = nil
290 } else {
291 ctxLines := g.ctxLines
292 if ctxLines > len(g.afterContext) {
293 ctxLines = len(g.afterContext)
294 }
295 g.current.AddOp(Equal, g.afterContext[:ctxLines]...)
296 g.hunks = append(g.hunks, g.current)
297
298 g.current = nil
299 g.beforeContext = g.afterContext[ctxLines:]
300 g.afterContext = nil
301 }
302}
303
304func splitLines(s string) []string {
305 out := splitLinesRegexp.FindAllString(s, -1)

Callers 1

GenerateMethod · 0.95

Calls 1

AddOpMethod · 0.80

Tested by

no test coverage detected