Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] RevWalk not iterating over any commits

Hello jgit devs,

the API of RevWalk is quite ambiguous. When creating a RevWalk from a Repository, shouldn't that RevWalk contain all commits of that repository, or at least any? The constructor taking a Repository does not state this.

When I create a RevWalk from a repository which has many branches and commits and then use it in a for each loop, the loop is left instantly as if there were no commits. However, when supplying a commit hash to revWalk.parseCommit(<HASH>), then the commit is found.

So what am I doing wrong here? I want to loop over all commits of a repository, prefarrably in a chronological order. Can you tell me how to do this best (since RevWalk seems not to do it)?

Here is an example stating my problem:

Repository repo = ...;
RevWalk walk = new RevWalk(repo);
for(RevCommit c : walk){
    System.out.println("contains a commit."); //Not shown!
}
MutableObjectId commitId = new MutableObjectId();
commitId.fromString("88fb303a316bab708da45f7864ae1176cb2e36fa");
Object c2 = walk.parseCommit(commitId);
if(c2 != null){
    System.out.println("specific commit found."); //Shown
}

the specific commit is found, looping over the walk does nothing. Also calling next() manually yields null.

Thanks in advance for your help.
Best regards,
Jan Finis


Back to the top