[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] How to get commits betwee two commits
|
Shawn, Chris,
thank you for your answers, they were very helpful.
Ákos
On Sun, Mar 27, 2011 at 10:08 PM, Shawn Pearce
<spearce@xxxxxxxxxxx> wrote:
On Sun, Mar 27, 2011 at 04:26, Akos Tajti <
akos.tajti@xxxxxxxxx> wrote:
> in our application there's a method that tries to get all commits between
> two commits (the same as git log since..until from command line). It seems
> that there's no method óin the JGit API that easily supports this so we
> implemented it for ourselves. It's a very simple method: we create a RevWalk
> starting from the first commit and go through the tree until we find the
> second commit. Something like this:
> walk.markStart(headCommit);
Actually its easier, do this:
RevWalk walk = ...;
walk.markStart(headCommit);
walk.markUninteresting(headId);
for (RevCommit next : walk) {
... loops over only the commits in headId..headCommit ...
}
The trick is markUnintereesting(), its the --not argument of git log.
Or use LogCommand like Chris suggested.
--
Shawn.