| Summary: | Incorrect traversing a commit DAG with RevWalk after marking certain commits uninteresting | ||
|---|---|---|---|
| Product: | [Technology] JGit | Reporter: | Slava Prisivko <vprisivko> |
| Component: | JGit | Assignee: | Project Inbox <jgit.core-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | ||
| Version: | 1.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
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.