Bug 354672 - Incorrect traversing a commit DAG with RevWalk after marking certain commits uninteresting
Summary: Incorrect traversing a commit DAG with RevWalk after marking certain commits ...
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 16:36 EDT by Slava Prisivko CLA
Modified: 2011-08-12 16:36 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Slava Prisivko CLA 2011-08-12 16:36:58 EDT
Consider the following snippet of code.

Input: gitRepo, headRevCommit representeting Git repository and head commit respectively.
<code>
    final RevWalk revWalk = new RevWalk(gitRepo);
    revWalk.sort(RevSort.TOPO);

    revWalk.markStart(headRevCommit);

    LinkedList<RevCommit> mainBranchCommits = new LinkedList<>();

    RevCommit currentCommit;

    while ((currentCommit = revWalk.next()) != null) {
      mainBranchCommits.addFirst(currentCommit);

      for (int i = 1; i < currentCommit.getParentCount(); ++i) {
        revWalk.markUninteresting(currentCommit.getParent(i));
      }
    }
</code>

It's aimed to single out the linear structure from a commit DAG.
Bug in case you have the following graph:

<code>
  1
 / \
2   3
|\  |
| \ |
|  \|
|   4
|   |
5

</code>

the order of traversal is the following: 1, 2, 4, 5. However, the commit 4 shouldn't be there.