I ran across the various log options for working with cherry-pick{able,ed} commits, I'm pretty sure some variation on
git log --decorate --oneline --cherry master...topic
will serve here (note the three dots).
For reference, git log and git revisions (ways to specify revisions and revision sets) docs.
To find the latest recorded merge of topic
to master
whether or not the topic
ref has since been deleted,
git log --oneline -1 --first-parent --merges --grep="^Merge branch 'topic'" master
and to remember it for later use do e.g.
merge=$(git log --pretty=%H -1 --first-parent --merges --grep="^Merge branch 'topic'")
so you can then
git log --decorate --oneline --cherry $merge^...$merge^2
Other options:
In the ordinary case topic
is still active and you only really care what change hunks merge is working with:
git diff master...topic
To find the latest recorded merge of topic
to master
if the topic
ref has since been deleted, i.e. if you're dealing with the archaeological case here:
git log --oneline -1 --first-parent --merges --grep="^Merge branch 'topic'" master
and you can set a variable for the merge and merged-tip commit ids with
merge=$(git log --pretty=%H -1 --first-parent --merges \
--grep="^Merge branch 'topic'" master)
topic=$(git rev-parse -q --verify $merge^2)
edit: someday I promise I'll stop giving keyboard-to-editbox commands. The above works now.
If you decided not to record the merge then of course there's no record of the merge.
Recorded merges can clutter up the commit graph and if there are many of them they can make it hard to follow; also, commit-message subjects are intended to be enough to identify the scope of the work done in them. So git ordinarily prefers linear histories when possible. To avoid depending on the commit subjects, to ensure administratively-significant boundaries are recorded in the ancestry chain (and for largeish projects this is often a really really good idea), do a merge and specify --no-ff
.
To get either the current topic
tip or failing that its most recently merged tip:
topic=$( git rev-parse -q --verify refs/heads/topic \
|| git rev-parse -q --verify $( git log --pretty=%H \
-1 --first-parent --merges \
--grep="^Merge branch 'topic'" master)^2 )
The first commit off master in $topic
's branch:
first=`git rev-list master..$topic --reverse --first-parent | sed q`
And that commit's first parent is the branch point from master:
branchbase=`git rev-parse $first^`
To show all the changes on $topic since the histories first diverged:
git diff $branchbase..$topic