Skip to content

Commit

Permalink
revision: allow setting custom limiter function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vicent Marti authored and Junio C Hamano committed Oct 24, 2013
1 parent 68fb36e commit a330de3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,10 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
return 0;
commit->object.flags |= ADDED;

if (revs->include_check &&
!revs->include_check(commit, revs->include_check_data))
return 0;

/*
* If the commit is uninteresting, don't try to
* prune parents - we want the maximal uninteresting
Expand Down
2 changes: 2 additions & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ struct rev_info {
unsigned long min_age;
int min_parents;
int max_parents;
int (*include_check)(struct commit *, void *);
void *include_check_data;

/* diff info for patches and for paths limiting */
struct diff_options diffopt;
Expand Down

0 comments on commit a330de3

Please sign in to comment.