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)
| 159 | // If the callback returns TreeWalkSkip, the passed entry will be skipped on |
| 160 | // the traversal. Any other non-nil error stops the walk. |
| 161 | func (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 | |
| 185 | type TreeBuilder struct { |
| 186 | doNotCompare |