Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
c8a1892e
Commit
c8a1892e
authored
Jul 20, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #831 from schu/tree-walk-order
tree: fix ordering for git_tree_walk
parents
71d27358
c6f42953
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
src/tree.c
+12
-8
No files found.
src/tree.c
View file @
c8a1892e
...
...
@@ -759,11 +759,12 @@ int git_tree_entry_bypath(
return
error
;
}
static
int
tree_walk
_post
(
static
int
tree_walk
(
git_tree
*
tree
,
git_treewalk_cb
callback
,
git_buf
*
path
,
void
*
payload
)
void
*
payload
,
bool
preorder
)
{
int
error
=
0
;
unsigned
int
i
;
...
...
@@ -771,8 +772,8 @@ static int tree_walk_post(
for
(
i
=
0
;
i
<
tree
->
entries
.
length
;
++
i
)
{
git_tree_entry
*
entry
=
tree
->
entries
.
contents
[
i
];
if
(
callback
(
path
->
ptr
,
entry
,
payload
)
<
0
)
continue
;
if
(
preorder
&&
callback
(
path
->
ptr
,
entry
,
payload
)
<
0
)
return
-
1
;
if
(
git_tree_entry__is_tree
(
entry
))
{
git_tree
*
subtree
;
...
...
@@ -789,12 +790,15 @@ static int tree_walk_post(
if
(
git_buf_oom
(
path
))
return
-
1
;
if
(
tree_walk
_post
(
subtree
,
callback
,
path
,
payload
)
<
0
)
if
(
tree_walk
(
subtree
,
callback
,
path
,
payload
,
preorder
)
<
0
)
return
-
1
;
git_buf_truncate
(
path
,
path_len
);
git_tree_free
(
subtree
);
}
if
(
!
preorder
&&
callback
(
path
->
ptr
,
entry
,
payload
)
<
0
)
return
-
1
;
}
return
0
;
...
...
@@ -807,12 +811,12 @@ int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payl
switch
(
mode
)
{
case
GIT_TREEWALK_POST
:
error
=
tree_walk
_post
(
tree
,
callback
,
&
root_path
,
payload
);
error
=
tree_walk
(
tree
,
callback
,
&
root_path
,
payload
,
false
);
break
;
case
GIT_TREEWALK_PRE
:
tree_error
(
"Preorder tree walking is still not implemented"
);
return
-
1
;
error
=
tree_walk
(
tree
,
callback
,
&
root_path
,
payload
,
true
);
break
;
default:
giterr_set
(
GITERR_INVALID
,
"Invalid walking mode for tree walk"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment