How to define a "In between" JGit RevFilter?
<p>I am trying to implement a <code>RevFilter</code> to be used through <code>RevWalk#setRevFilter()</code>.  In the following what I have tried:</p>

<pre><code>private class InBetweenRevFilter extends RevFilter {

    private AnyObjectId end;
    private AnyObjectId begin;

    public InBetweenRevFilter(AnyObjectId begin, AnyObjectId end) {
        this.begin = begin;
        this.end = end;
    }

    @Override
    public RevFilter clone() {
        return this;
    }

    @Override
    public boolean include(RevWalk walker, RevCommit c)
            throws StopWalkException, MissingObjectException,
            IncorrectObjectTypeException, IOException {
        RevCommit from = walker.parseCommit(begin);
        RevCommit to = walker.parseCommit(end);
        return (walker.isMergedInto(from, c) &amp;&amp; walker.isMergedInto(c, to));
    }
}
</code></pre>

<p>The result of the filter should be the commit pushed after the <code>begin</code> and before the <code>end</code>. The problem is that when I set this filter, only the commit marked as the start point with <code>RevWalk.markStart(RevCommit c)</code> is returned by the <code>RevWalk.next()</code>. In the following, I show show how I tried to use the filter:</p>

<pre><code>    RevWalk walk = new RevWalk(getRepository());
    RevCommit beginCommit = walk.parseCommit(getRepository().resolve(start));
    RevCommit endCommit = walk.parseCommit(getRepository().resolve(end));
    walk.setRevFilter(new InBetweenRevFilter(beginCommit.getId(), endCommit.getId()));
    walk.markStart(endCommit);
    for (RevCommit rev : walk) {
        System.out.println(rev.getFullMessage());
    }
    walk.close();
</code></pre>

<p>In this example, only the message from <code>endCommit</code> printed in the console. Is there any other way to do this? Or, what am I missing or did wrong?</p>