Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Duplicate RevCommits in RevWalk
Duplicate RevCommits in RevWalk [message #1696421] Tue, 26 May 2015 11:53
Ruici Luo is currently offline Ruici LuoFriend
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

Previous Topic:[Solved] Clone submodules in JGit
Next Topic:Project is forgetting it's tied to a EGIT repo
Goto Forum:
  


Current Time: Fri Apr 19 14:58:12 GMT 2024

Powered by FUDForum. Page generated in 0.01343 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top