MCPcopy
hub / github.com/git-lfs/git-lfs / ProcessLines

Method ProcessLines

git/gitattr/macro.go:26–69  ·  view source on GitHub ↗

ProcessLines reads the specified lines, returning a new set of lines which all have a valid pattern. If readMacros is true, it additionally loads any macro lines as it reads them.

(lines []Line, readMacros bool)

Source from the content-addressed store, hash-verified

24// all have a valid pattern. If readMacros is true, it additionally loads any
25// macro lines as it reads them.
26func (mp *MacroProcessor) ProcessLines(lines []Line, readMacros bool) []PatternLine {
27 result := make([]PatternLine, 0, len(lines))
28 for _, line := range lines {
29 switch l := line.(type) {
30 case PatternLine:
31 var lineAttrs lineAttrs
32 lineAttrs.attrs = make([]*Attr, 0, len(l.Attrs()))
33
34 resultLine := &patternLine{l.Pattern(), lineAttrs}
35 for _, attr := range l.Attrs() {
36 macros := mp.macros[attr.K]
37 if attr.V == "true" && macros != nil {
38 resultLine.attrs = append(
39 resultLine.attrs,
40 macros...,
41 )
42 } else if attr.Unspecified && macros != nil {
43 for _, m := range macros {
44 resultLine.attrs = append(
45 resultLine.attrs,
46 &Attr{
47 K: m.K,
48 Unspecified: true,
49 },
50 )
51 }
52 }
53
54 // Git copies through aliases as well as
55 // expanding them.
56 resultLine.attrs = append(
57 resultLine.attrs,
58 attr,
59 )
60 }
61 result = append(result, resultLine)
62 case MacroLine:
63 if readMacros {
64 mp.macros[l.Macro()] = l.Attrs()
65 }
66 }
67 }
68 return result
69}

Calls 3

AttrsMethod · 0.65
PatternMethod · 0.65
MacroMethod · 0.65