tags:

views:

45

answers:

2

We're about to move from svn to git, and one of my users has a question. We have a number of long-lived release branches. Periodically they get tagged (rel_foo_10) and merged back to the master. We need to be able to list all the commits that were made on the release branch. Doing git log master..rel_foo_10 (show all commits reachable from rel_foo_10 but not from master) doesn't work because after the merge all commits are reachable from the tip of master. Is this possible in git?

One idea would be to find the oldest branch point and do git log branchpoint..rel_foo_10. Is that easy? (git merge-base doesn't seem to do it, since it finds the latest common ancestor and I want the earliest).

Or what about git show-branch? It's not clear to me from the man page how that command knows when to stop.

A: 

Last time I checked, this isn't handled directly by git. I had the same need: I wanted my live site update script to email to everyone all the changes that have been merged. I didn't find any tool that lets me easily parse the repo history to tell me when the branches started to differ. In other words I couldn't programmatically find the earliest common ancestor.

This the solutions I came up with: just create a branch off of master before merging. This branch may be permanent if you like or in my case it's temporary:

git branch temp

Now when you merge you have a reference of where the merge started:

git merge rel_foo_10
git log temp..HEAD

Once I saved the log to file I can delete the temp branch. If you plan to make the pre-merge branch permanent then maybe you can name it using some convention like pre_rel_foo_10 for example.

slebetman
I don't think that's what I'm looking for. I want to see all the changes on the branch, even if it was merged to trunk several times. I don't just want to see the changes that make up a single merge (though that's a good idea too!) I guess we could make a tag when we *start* the branch, and use that as the left side of the .. operator. Seems like git should be able to tell me this though.
garyo
+1  A: 

Best solution I've seen so far anywhere on the net is this one (actually this is modified from the ones I found, to use --date-order which is necessary to order the boundary commits properly):

base=`git rev-list --boundary release_branch...master --date-order | \
   grep '^-' | tail -1 | cut -c2-`
git log $base..release_branch

Is this the best/only way to get the (oldest) branch base in git?

garyo