I have to create some code review from unmerged branches.
In finding solutions, let\'s not go to local-branch context problem as this will run on a server; there wil
I would suggest doing it kind of the way you described it. But I would work on the output of git log --format="%H:%P:%s" ^origin/master origin/branch1 origin/branch2, so you can do better tree-walking.
git rev-parse). Mark every commit with the names of the head you came from and its distance.
commit -> known-name. Now for each of your commits, you will have a list of distance values (that might be negative) to your branch heads. For each commit, the branch with the least distance is the one the commit was most likely created on.
If you have time, you might want to walk the whole history and then substract the history of master – that might give slightly better results if your branches have been merged into master before.
Couldn’t resist: Made a python script that does what I described. But with one change: with every normal step, the distance is not increased, but decreased. This has the effect that branches that lived longer after a merge-point are preferred, which I personally like more. Here it is: https://gist.github.com/Chronial/5275577
Usage: simply run git-annotate-log.py ^origin/master origin/branch1 origin/branch2 check the quality of the results (will output a git log tree with annotations).