]> source.dussan.org Git - jgit.git/commit
RevWalk: stop mixing lines of history in topo sort 26/157526/14
authorAlex Spradlin <alexaspradlin@google.com>
Tue, 11 Feb 2020 21:27:51 +0000 (13:27 -0800)
committerAlex Spradlin <alexaspradlin@google.com>
Tue, 18 Feb 2020 23:17:23 +0000 (15:17 -0800)
commitb5e764abd21bd4593287361a625ecc49bc0efd77
tree87a1f9ad65d8e42c7ad77e14f3e1b6d38ed24255
parente68e0e7f034e371841b626bb4e858134483bad03
RevWalk: stop mixing lines of history in topo sort

The topological sort algorithm in TopoSortGenerator for RevWalk may mix
multiple lines of history, producing results that differ from C git's
git log whose man page states: "Show no parents before all of its
children are shown, and avoid showing commits on multiple lines of
history intermixed." Lines of history are mixed because
TopoSortGenerator merely delays a commit until all of its children have
been produced; it does not immediately produce a commit after its last
child has been produced.

Therefore, when the last child of a commit has been produced, unpop the
commit so that it will be returned upon the subsequent call to next() in
TopoSortGenerator. To avoid producing duplicates, mark commits that
have not yet been produced as TOPO_QUEUED so that when a commit is
popped, it is produced if and only if TOPO_QUEUED is set.

To support nesting with other generators that may produce the same
commit multiple times like DepthGenerator (for example, StartGenerator
does this), do not increment parent inDegree for the same child commit
more than once.

Modify tests that assert that TopoSortGenerator mixes lines of commit
history.

Change-Id: I4ee03c7a8e5265d61230b2a01ae3858745b2432b
Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkSortTest.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObject.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TopoSortGenerator.java