Is there any way to replicate an inheritance tree of Git branches in shell?
For example, I have local branches b1, b2, ... , bN as listed by git branch
.
Example:
++ b7 <--+ b4
|
b8 <--+ b5 +-+ b2
| |
++ b1 <---+ b3
|
+-+ b6
So, in the above case I would like to have a variables representing branch names (or their hashes, doesn't matter).
I know about binary search tree data structures in shell (at least one approach which is working nicely). The problem is how to get a proper left or right choice when submitting the branch into the BST-like structure?
I suppose I need to do something with git branch --contains
and git merge-base
, though I can't clearly see a picture of algorithm right now. The git branch --contains
works quite slowly, perhaps because of nature of the tree, it would be also good to hear alternatives.
libgit2
+ python approach seems not the best choice to me because I need to rebase those branches and it looks like libgit2
is quite low level for that.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…