Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

sh - Tree of inheritance of Git branches

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Does this command's output look like what you want:

git log --oneline --graph --decorate --simplify-by-decoration --all

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...