mlange-42 / git-graph

Command line tool to show clear git graphs arranged for your branching model
MIT License
542 stars 21 forks source link

Better branch sorting algorithms #8

Closed mlange-42 closed 3 years ago

mlange-42 commented 3 years ago

Currently, there are several branch sorting algorithms that are all suboptimal. The "best" so in most cases is ShortestFirst, which tries to keep short paths left (i.e. close to e.g. master or develop), where they in most cases branched from and merge into.

However, e.g. when branching from a feature branch and merging back into it, the results may be unsatisfying.

Optimally, the sorting algorithm would optimize the layout to minimize intersections between branches and merge/branch connections (i.e. non-vertical lines). A possible strategy would be to achieve that implicitly by trying to keep branches close to their "source" and/or "target". A more sophisticated strategy might optimize for minimal intersections explicitly.