libgit2

git_tree_walk

Version:

Traverse the entries in a tree and its subtrees in post or pre order

The entries will be traversed in the specified 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.

If the callback returns a negative value, the passed entry will be skiped on the traversal.

Signature

int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);

Parameters

In
tree

The tree to walk

In
callback

Function to call on each tree entry

int
In
mode

Traversal mode (pre or post-order)

void *
In
payload

Opaque pointer to be passed on each callback

Returns

int

GIT_SUCCESS or an error code

Versions