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

Method Children

plumbing/object/treenoder.go:70–94  ·  view source on GitHub ↗

Children will return the children of a treenoder as treenoders, building them from the children of the wrapped git tree.

()

Source from the content-addressed store, hash-verified

68// Children will return the children of a treenoder as treenoders,
69// building them from the children of the wrapped git tree.
70func (t *treeNoder) Children() ([]noder.Noder, error) {
71 if t.mode != filemode.Dir {
72 return noder.NoChildren, nil
73 }
74
75 // children are memoized for efficiency
76 if t.children != nil {
77 return t.children, nil
78 }
79
80 // the parent of the returned children will be ourself as a tree if
81 // we are a not the root treenoder. The root is special as it
82 // is is own parent.
83 parent := t.parent
84 if !t.isRoot() {
85 var err error
86 if parent, err = t.parent.Tree(t.name); err != nil {
87 return nil, err
88 }
89 }
90
91 var err error
92 t.children, err = transformChildren(parent)
93 return t.children, err
94}
95
96// Returns the children of a tree as treenoders.
97// Efficiency is key here.

Callers 1

NumChildrenMethod · 0.95

Calls 3

isRootMethod · 0.95
transformChildrenFunction · 0.85
TreeMethod · 0.65

Tested by

no test coverage detected