revision: allow setting custom limiter function
This commit enables users of `struct rev_info` to peform custom limiting during a revision walk (i.e. `get_revision`). If the field `include_check` has been set to a callback, this callback will be issued once for each commit before it is added to the "pending" list of the revwalk. If the include check returns 0, the commit will be marked as added but won't be pushed to the pending list, effectively limiting the walk. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Vicent Marti committed
Oct 24, 2013 at 14:01 UTC
a330de31d18ca08c773c64e3657b3bafd59cf751
2 files changed
+6
revision.c
+4
@@ -779,6 +779,10 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
779
return 0;
780
commit->object.flags |= ADDED;
781
782
+ if (revs->include_check &&
783
+ !revs->include_check(commit, revs->include_check_data))
784
+ return 0;
785
+
786
/*
787
* If the commit is uninteresting, don't try to
788
* prune parents - we want the maximal uninteresting
revision.h
+2
@@ -168,6 +168,8 @@ struct rev_info {
168
unsigned long min_age;
169
int min_parents;
170
int max_parents;
171
+ int (*include_check)(struct commit *, void *);
172
+ void *include_check_data;
173
174
/* diff info for patches and for paths limiting */
175
struct diff_options diffopt;