summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-03-25 10:33:18 -0700
committerEdward Thomson <ethomson@edwardthomson.com>2014-03-25 10:33:18 -0700
commit451aaf866af2d974380a2d141626f450212f40f2 (patch)
tree780c2db94ab7f589c646fa3fb05375031bdc830c /src
parentf210cb5b1442f82e2f930909d8430f7cc6661c5f (diff)
parent34ffe22344d32d1574dc33d3c3d20556fdb152a7 (diff)
downloadlibgit2-451aaf866af2d974380a2d141626f450212f40f2.tar.gz
Merge pull request #2181 from anuraggup/hide_cb
Callback function to hide commit and its parents in revision walker
Diffstat (limited to 'src')
-rw-r--r--src/revwalk.c30
-rw-r--r--src/revwalk.h4
2 files changed, 29 insertions, 5 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index f037ee692..f0109360b 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -81,6 +81,9 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h
{
int error;
+ if (!hide && walk->hide_cb)
+ hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload);
+
if (hide && mark_uninteresting(commit) < 0)
return -1;
@@ -178,11 +181,6 @@ static int push_ref(git_revwalk *walk, const char *refname, int hide, int from_g
return push_commit(walk, &oid, hide, from_glob);
}
-struct push_cb_data {
- git_revwalk *walk;
- int hide;
-};
-
static int push_glob(git_revwalk *walk, const char *glob, int hide)
{
int error = 0;
@@ -575,3 +573,25 @@ void git_revwalk_reset(git_revwalk *walk)
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;
+}
+
diff --git a/src/revwalk.h b/src/revwalk.h
index a0ce1ae86..a0654f3e5 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -39,6 +39,10 @@ struct git_revwalk {
/* merge base calculation */
git_commit_list_node *one;
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);