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
2ba14f23
Commit
2ba14f23
authored
Nov 17, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: Add payload to `git_tree_walk`
parent
9432af36
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
include/git2/tree.h
+2
-2
src/tree.c
+9
-5
No files found.
include/git2/tree.h
View file @
2ba14f23
...
...
@@ -284,7 +284,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr
GIT_EXTERN
(
int
)
git_tree_get_subtree
(
git_tree
**
subtree
,
git_tree
*
root
,
const
char
*
subtree_path
);
/** Callback for the tree traversal method */
typedef
int
(
*
git_treewalk_cb
)(
const
char
*
root
,
git_tree_entry
*
entry
);
typedef
int
(
*
git_treewalk_cb
)(
const
char
*
root
,
git_tree_entry
*
entry
,
void
*
payload
);
/** Tree traversal modes */
enum
git_treewalk_mode
{
...
...
@@ -310,7 +310,7 @@ enum git_treewalk_mode {
* @param mode Traversal mode (pre or post-order)
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN
(
int
)
git_tree_walk
(
git_tree
*
walk
,
git_treewalk_cb
callback
,
int
mode
);
GIT_EXTERN
(
int
)
git_tree_walk
(
git_tree
*
walk
,
git_treewalk_cb
callback
,
int
mode
,
void
*
payload
);
/** @} */
GIT_END_DECL
...
...
src/tree.c
View file @
2ba14f23
...
...
@@ -683,7 +683,8 @@ static int tree_walk_post(
git_tree
*
tree
,
git_treewalk_cb
callback
,
char
*
root
,
size_t
root_len
)
size_t
root_len
,
void
*
payload
)
{
int
error
;
unsigned
int
i
;
...
...
@@ -693,7 +694,7 @@ static int tree_walk_post(
root
[
root_len
]
=
'\0'
;
if
(
callback
(
root
,
entry
)
<
0
)
if
(
callback
(
root
,
entry
,
payload
)
<
0
)
continue
;
if
(
ENTRY_IS_TREE
(
entry
))
{
...
...
@@ -707,7 +708,10 @@ static int tree_walk_post(
root
[
root_len
+
entry
->
filename_len
]
=
'/'
;
tree_walk_post
(
subtree
,
callback
,
root
,
root_len
+
entry
->
filename_len
+
1
);
callback
,
root
,
root_len
+
entry
->
filename_len
+
1
,
payload
);
git_tree_close
(
subtree
);
}
...
...
@@ -716,14 +720,14 @@ static int tree_walk_post(
return
GIT_SUCCESS
;
}
int
git_tree_walk
(
git_tree
*
tree
,
git_treewalk_cb
callback
,
int
mode
)
int
git_tree_walk
(
git_tree
*
tree
,
git_treewalk_cb
callback
,
int
mode
,
void
*
payload
)
{
char
root_path
[
GIT_PATH_MAX
];
root_path
[
0
]
=
'\0'
;
switch
(
mode
)
{
case
GIT_TREEWALK_POST
:
return
tree_walk_post
(
tree
,
callback
,
root_path
,
0
);
return
tree_walk_post
(
tree
,
callback
,
root_path
,
0
,
payload
);
case
GIT_TREEWALK_PRE
:
return
git__throw
(
GIT_ENOTIMPLEMENTED
,
...
...
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