mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 13:52:17 +00:00
Callback to hide commits in revision walker.
This commit is contained in:
parent
f57cc63811
commit
892aa808e2
@ -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
|
||||||
|
@ -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)
|
|||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user