mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 12:24:11 +00:00
Merge pull request #873 from carlosmn/tree-walk
git_tree_walk callback return value semantic does not match documentation
This commit is contained in:
commit
85f28ba891
@ -351,8 +351,9 @@ enum git_treewalk_mode {
|
|||||||
* the current (relative) root for the entry and the entry
|
* the current (relative) root for the entry and the entry
|
||||||
* data itself.
|
* data itself.
|
||||||
*
|
*
|
||||||
* If the callback returns a negative value, the passed entry
|
* If the callback returns a positive value, the passed entry will be
|
||||||
* will be skipped on the traversal.
|
* skipped on the traversal (in pre mode). A negative value stops the
|
||||||
|
* walk.
|
||||||
*
|
*
|
||||||
* @param tree The tree to walk
|
* @param tree The tree to walk
|
||||||
* @param callback Function to call on each tree entry
|
* @param callback Function to call on each tree entry
|
||||||
|
11
src/tree.c
11
src/tree.c
@ -787,9 +787,12 @@ static int tree_walk(
|
|||||||
for (i = 0; i < tree->entries.length; ++i) {
|
for (i = 0; i < tree->entries.length; ++i) {
|
||||||
git_tree_entry *entry = tree->entries.contents[i];
|
git_tree_entry *entry = tree->entries.contents[i];
|
||||||
|
|
||||||
if (preorder && callback(path->ptr, entry, payload)) {
|
if (preorder) {
|
||||||
error = GIT_EUSER;
|
error = callback(path->ptr, entry, payload);
|
||||||
break;
|
if (error > 0)
|
||||||
|
continue;
|
||||||
|
if (error < 0)
|
||||||
|
return GIT_EUSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (git_tree_entry__is_tree(entry)) {
|
if (git_tree_entry__is_tree(entry)) {
|
||||||
@ -815,7 +818,7 @@ static int tree_walk(
|
|||||||
git_tree_free(subtree);
|
git_tree_free(subtree);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preorder && callback(path->ptr, entry, payload)) {
|
if (!preorder && callback(path->ptr, entry, payload) < 0) {
|
||||||
error = GIT_EUSER;
|
error = GIT_EUSER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user