MCPcopy Create free account
hub / github.com/libgit2/git2go / Walk

Method Walk

tree.go:161–183  ·  view source on GitHub ↗

Walk traverses the entries in a tree and its subtrees in pre order. The entries will be traversed in the pre order, children subtrees will be automatically loaded as required, and the callback will be called once per entry with the current (relative) root for the entry and the entry data itself. I

(callback TreeWalkCallback)

Source from the content-addressed store, hash-verified

159// If the callback returns TreeWalkSkip, the passed entry will be skipped on
160// the traversal. Any other non-nil error stops the walk.
161func (t *Tree) Walk(callback TreeWalkCallback) error {
162 var err error
163 data := treeWalkCallbackData{
164 callback: callback,
165 errorTarget: &err,
166 }
167 runtime.LockOSThread()
168 defer runtime.UnlockOSThread()
169
170 handle := pointerHandles.Track(&data)
171 defer pointerHandles.Untrack(handle)
172
173 ret := C._go_git_treewalk(t.cast_ptr, C.GIT_TREEWALK_PRE, handle)
174 runtime.KeepAlive(t)
175 if ret == C.int(ErrorCodeUser) && err != nil {
176 return err
177 }
178 if ret < 0 {
179 return MakeGitError(ret)
180 }
181
182 return nil
183}
184
185type TreeBuilder struct {
186 doNotCompare

Callers 3

TestTreeWalkFunction · 0.45
TestTreeWalkSkipFunction · 0.45
TestTreeWalkStopFunction · 0.45

Calls 3

MakeGitErrorFunction · 0.85
TrackMethod · 0.80
UntrackMethod · 0.80

Tested by 3

TestTreeWalkFunction · 0.36
TestTreeWalkSkipFunction · 0.36
TestTreeWalkStopFunction · 0.36