Re: git log for a merged branch
- From
Michele Ballabio <barra_cuda@katamail.com>
- Date
- Sep 8, 2010, 23:17 UTC
- Message-ID
- <201009090117.06555.barra_cuda@katamail.com>
- In-Reply-To
- <14267801.230161.1283954674012.JavaMail.root@mail.hq.genarts.com>
On Wednesday 08 September 2010, Stephen Bash wrote:
Show 15 quoted lines
> Assume I have a release branch with bug fixes that is tagged at the end of > the release cycle (let's call the tag tagFoo). The release branch then > gets merged back into mainline development (call the branch mainline), and > the release branch is deleted. If I want to see the commits (bug fixes) > performed on the release branch, how do I do it? > > I don't think > git log mainline..tagFoo > works because all the commits of tagFoo are now reachable by mainline > thanks to the merge. Is there a simple way to express this concept? > > Obviously in a pinch a simple > git log tagFoo > will give you everything back to the beginning of time, but I think that's > suboptimal...
Let's call the merge commit "mergecmt". The commit where the "release" branch branched off is
git merge-base mergecmt^1 mergecmt^2
... where mergecmt^1 is the first parent of the merge (usually on the "mainline" branch) and mergecmt^2 is the second parent, which usually(*) refers to the "release" branch (in this case, tagFoo).
So
git log $(git merge-base mergecmt^1 mergecmt^2)..mergecmt^2
is what you want.
> To complicate things a bit more, in the real world there may be multiple > merges from the release branch to mainline during the life of the release > branch, so any solution that also deals with that would be outstanding > (probably at the cost of additional complexity?)
Maybe something like:
for i in $(git rev-list --merges last_interesting_tag..mainline) do git log $(git merge-base $i^1 $i^2)..$i^2 done
... or maybe using GIT_PAGER='':
for i in $(git rev-list --merges last_interesting_tag..mainline) do GIT_PAGER='' git log $(git merge-base $i^1 $i^2)..$i^2 done
(*) I don't remember the details, but if you do the standard "git pull" or "git merge" and don't use the plumbing commands in a weird way to badly reimplement "merge" or "pull", you should be safe. Others may want to comment on this, though.