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
892aa808
Commit
892aa808
authored
Mar 10, 2014
by
Anurag Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Callback to hide commits in revision walker.
parent
f57cc638
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
include/git2/revwalk.h
+24
-0
src/revwalk.c
+28
-0
src/revwalk.h
+4
-0
No files found.
include/git2/revwalk.h
View file @
892aa808
...
@@ -261,6 +261,30 @@ GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk);
...
@@ -261,6 +261,30 @@ GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk);
*/
*/
GIT_EXTERN
(
git_repository
*
)
git_revwalk_repository
(
git_revwalk
*
walk
);
GIT_EXTERN
(
git_repository
*
)
git_revwalk_repository
(
git_revwalk
*
walk
);
/**
* This is a callback function that user can provide to hide a
* commit and its parents. If the callback function returns true,
* then this commit and its parents will be hidden.
*
* @param commit_id oid of Commit
* @param payload User-specified pointer to data to be passed as data payload
*/
typedef
int
(
*
git_revwalk_hide_cb
)(
const
git_oid
*
commit_id
,
void
*
payload
);
/**
* Adds a callback function to hide a commit
*
* @param walk the revision walker
* @param hide_cb callback function to hide a commit and its parents
* @param payload data payload to be passed to callback function
*/
GIT_EXTERN
(
int
)
git_revwalk_add_hide_cb
(
git_revwalk
*
walk
,
git_revwalk_hide_cb
hide_cb
,
void
*
payload
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
#endif
#endif
src/revwalk.c
View file @
892aa808
...
@@ -81,6 +81,11 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h
...
@@ -81,6 +81,11 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h
{
{
int
error
;
int
error
;
if
(
!
hide
&&
walk
->
hide_cb
)
{
hide
=
walk
->
hide_cb
(
&
commit
->
oid
,
walk
->
hide_cb_payload
);
}
if
(
hide
&&
mark_uninteresting
(
commit
)
<
0
)
if
(
hide
&&
mark_uninteresting
(
commit
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -575,3 +580,26 @@ void git_revwalk_reset(git_revwalk *walk)
...
@@ -575,3 +580,26 @@ void git_revwalk_reset(git_revwalk *walk)
git_vector_clear
(
&
walk
->
twos
);
git_vector_clear
(
&
walk
->
twos
);
}
}
int
git_revwalk_add_hide_cb
(
git_revwalk
*
walk
,
git_revwalk_hide_cb
hide_cb
,
void
*
payload
)
{
assert
(
walk
);
if
(
walk
->
walking
)
git_revwalk_reset
(
walk
);
if
(
walk
->
hide_cb
)
{
/* There is already a callback added */
giterr_set
(
GITERR_INVALID
,
"There is already a callback added to hide commits in revision walker."
);
return
-
1
;
}
walk
->
hide_cb
=
hide_cb
;
walk
->
hide_cb_payload
=
payload
;
return
0
;
}
src/revwalk.h
View file @
892aa808
...
@@ -39,6 +39,10 @@ struct git_revwalk {
...
@@ -39,6 +39,10 @@ struct git_revwalk {
/* merge base calculation */
/* merge base calculation */
git_commit_list_node
*
one
;
git_commit_list_node
*
one
;
git_vector
twos
;
git_vector
twos
;
/* hide callback */
git_revwalk_hide_cb
hide_cb
;
void
*
hide_cb_payload
;
};
};
git_commit_list_node
*
git_revwalk__commit_lookup
(
git_revwalk
*
walk
,
const
git_oid
*
oid
);
git_commit_list_node
*
git_revwalk__commit_lookup
(
git_revwalk
*
walk
,
const
git_oid
*
oid
);
...
...
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