fork of go-git with some jj specific features
at main 1.1 kB view raw
1package commitgraph 2 3import ( 4 "github.com/go-git/go-git/v5/plumbing" 5 6 "github.com/emirpasic/gods/trees/binaryheap" 7) 8 9// NewCommitNodeIterDateOrder returns a CommitNodeIter that walks the commit history, 10// starting at the given commit and visiting its parents in Committer Time and Generation order, 11// but with the constraint that no parent is emitted before its children are emitted. 12// 13// This matches `git log --date-order` 14func NewCommitNodeIterDateOrder(c CommitNode, 15 seenExternal map[plumbing.Hash]bool, 16 ignore []plumbing.Hash, 17) CommitNodeIter { 18 seen := make(map[plumbing.Hash]struct{}) 19 for _, h := range ignore { 20 seen[h] = struct{}{} 21 } 22 for h, ext := range seenExternal { 23 if ext { 24 seen[h] = struct{}{} 25 } 26 } 27 inCounts := make(map[plumbing.Hash]int) 28 29 exploreHeap := &commitNodeHeap{binaryheap.NewWith(generationAndDateOrderComparator)} 30 exploreHeap.Push(c) 31 32 visitHeap := &commitNodeHeap{binaryheap.NewWith(generationAndDateOrderComparator)} 33 visitHeap.Push(c) 34 35 return &commitNodeIteratorTopological{ 36 exploreStack: exploreHeap, 37 visitStack: visitHeap, 38 inCounts: inCounts, 39 ignore: seen, 40 } 41}