Duplicate RevCommits in RevWalk [message #1696421] |
Tue, 26 May 2015 11:53 |
Ruici Luo Messages: 7 Registered: March 2012 |
Junior Member |
|
|
Scenario:
I want to traverse a repository with multiple branches, e.g.:
C1->C2->C3->C4
branch dev refs C3 while master refs C4.
There are 4 commits and 2 branches in the repository. I want to traverse the repository according to the branch collection and get the whole commits. The expected set is : {C1, C2, C3, C4}.
Code:
Collection<RevCommit> branches;
final RevWalk walk = new RevWalk(repo);
RevCommit commit;
walk.setRetainBody(true);
try {
walk.markStart(branches);
while ((commit = walk.next()) != null) {
logger.info("commit = {}", commit);
}
} catch (IOException e) {
throw new GitException(e, repo);
} finally {
walk.close();
}
but the result is that I get a collection with duplicated elements: {C1, C2, C2, C3, C3, C4}
Can anyone help me solve this issue? Thank you very much.
[Updated on: Tue, 26 May 2015 12:03] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03520 seconds