{"thread":{"id":"25035","subject":"git log for a merged branch","startedAt":"2010-09-08T14:04:34Z","lastAt":"2010-09-13T14:43:59Z","messageCount":8,"participants":["Stephen Bash","Tor Arntsen","Michele Ballabio","Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"150294","messageId":"14267801.230161.1283954674012.JavaMail.root@mail.hq.genarts.com","threadId":"25035","inReplyTo":"22744209.230141.1283954076245.JavaMail.root@mail.hq.genarts.com","subject":"git log for a merged branch","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-09-08T14:04:34Z","receivedAt":"2010-09-08T14:04:34Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"Hi everyone-\n\nA coworker asked me a Git question yesterday that I can't answer, so I thought I'd pass it along:\n\nAssume 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?\n\nI don't think\n   git log mainline..tagFoo\nworks because all the commits of tagFoo are now reachable by mainline thanks to the merge.  Is there a simple way to express this concept?\n\nObviously in a pinch a simple\n   git log tagFoo\nwill give you everything back to the beginning of time, but I think that's suboptimal...\n\nTo 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?)\n\nThanks,\nStephen\n"},{"id":"150296","messageId":"AANLkTimSHrmQgcrx-CqMgvkcBdgBG9icqw934+7qP7kg@mail.gmail.com","threadId":"25035","inReplyTo":"14267801.230161.1283954674012.JavaMail.root@mail.hq.genarts.com","subject":"Re: git log for a merged branch","fromName":"Tor Arntsen","fromEmail":"tor@spacetec.no","sentAt":"2010-09-08T14:23:47Z","receivedAt":"2010-09-08T14:23:47Z","isPatch":false,"sender":{"key":"tor@spacetec.no","avatar":null},"body":"On Wed, Sep 8, 2010 at 16:04, Stephen Bash <bash@genarts.com> wrote:\n> Hi everyone-\n>\n> A coworker asked me a Git question yesterday that I can't answer, so I thought I'd pass it along:\n>\n> 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?\n[..]\n\nMaybe not exactly what you ask for, but the way I do it is simply to\nuse a non-ff merge with additional logging, i.e. git merge --no-ff\n--log <branchname-with-fixes>\nwhich will give me a merge commit which includes one-liners for each\nof those commits merged into mainline. And I include problem report\nID's in the first line of my commits I get a nice list of fixes, in a\ncommit looking something like this:\n\ncommit <sha1>\nAuthor:\nDate:\n   Merge branch 'fixes'\n  * fixes:\n     Fix for PR#23\n     Fix for PR#1\n     Fix for PR#288\n..\nand so on. Those 'Fix for' are just the git log --oneline of what got merged.\n(Obviously what you don't see in the above is the actual sha1 of each\nof those commits that got merged, but at least it's easy enough to\nfigure out what to put in the release notes :-)\n"},{"id":"150304","messageId":"7551190.230240.1283959342943.JavaMail.root@mail.hq.genarts.com","threadId":"25035","inReplyTo":"AANLkTimSHrmQgcrx-CqMgvkcBdgBG9icqw934+7qP7kg@mail.gmail.com","subject":"Re: git log for a merged branch","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-09-08T15:22:22Z","receivedAt":"2010-09-08T15:22:22Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"----- Original Message -----\n> From: \"Tor Arntsen\" <tor@spacetec.no>\n> To: \"Stephen Bash\" <bash@genarts.com>\n> Cc: \"Git Mailing List\" <git@vger.kernel.org>\n> Sent: Wednesday, September 8, 2010 10:23:47 AM\n> Subject: Re: git log for a merged branch\n> On Wed, Sep 8, 2010 at 16:04, Stephen Bash <bash@genarts.com> wrote:\n>\n> > If I want to\n> > see the commits (bug fixes) performed on the release branch, how do\n> > I do it?\n> [..]\n> \n> Maybe not exactly what you ask for, but the way I do it is simply to\n> use a non-ff merge with additional logging, i.e. git merge --no-ff\n> --log <branchname-with-fixes>\n> which will give me a merge commit which includes one-liners for each\n> of those commits merged into mainline.\n\nThat's actually a pretty cool trick.  I will file that one for adoption as we move to a git-centric workflow.\n\nI'm still curious if there's an \"easy\" way to extract the segment of history that was the release branch because I feel like there may be other uses than just git log... (not that I've nailed them down yet)\n\nThanks!\nStephen\n"},{"id":"150333","messageId":"201009090117.06555.barra_cuda@katamail.com","threadId":"25035","inReplyTo":"14267801.230161.1283954674012.JavaMail.root@mail.hq.genarts.com","subject":"Re: git log for a merged branch","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2010-09-08T23:17:05Z","receivedAt":"2010-09-08T23:17:05Z","isPatch":false,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"On Wednesday 08 September 2010, Stephen Bash wrote:\n> Assume I have a release branch with bug fixes that is tagged at the end of\n> the release cycle (let's call the tag tagFoo).  The release branch then\n> gets merged back into mainline development (call the branch mainline), and\n> the release branch is deleted.  If I want to see the commits (bug fixes)\n> performed on the release branch, how do I do it?\n> \n> I don't think\n>    git log mainline..tagFoo\n> works because all the commits of tagFoo are now reachable by mainline\n> thanks to the merge.  Is there a simple way to express this concept?\n> \n> Obviously in a pinch a simple\n>    git log tagFoo\n> will give you everything back to the beginning of time, but I think that's\n> suboptimal...\n\nLet's call the merge commit \"mergecmt\". The commit where the \"release\" branch\nbranched off is\n\n\tgit merge-base mergecmt^1 mergecmt^2\n\n... where mergecmt^1 is the first parent of the merge (usually on the\n\"mainline\" branch) and mergecmt^2 is the second parent, which usually(*)\nrefers to the \"release\" branch (in this case, tagFoo).\n\nSo\n\n\tgit log $(git merge-base mergecmt^1 mergecmt^2)..mergecmt^2\n\nis what you want.\n\n> To complicate things a bit more, in the real world there may be multiple\n> merges from the release branch to mainline during the life of the release\n> branch, so any solution that also deals with that would be outstanding\n> (probably at the cost of additional complexity?)\n\nMaybe something like:\n\n\tfor i in $(git rev-list --merges last_interesting_tag..mainline)\n\tdo\n\t\tgit log $(git merge-base $i^1 $i^2)..$i^2\n\tdone\n\n... or maybe using GIT_PAGER='':\n\n\tfor i in $(git rev-list --merges last_interesting_tag..mainline)\n\tdo\n\t\tGIT_PAGER='' git log $(git merge-base $i^1 $i^2)..$i^2\n\tdone\n\n(*) I don't remember the details, but if you do the standard \"git pull\"\nor \"git merge\" and don't use the plumbing commands in a weird way to badly\nreimplement \"merge\" or \"pull\", you should be safe. Others may want to\ncomment on this, though.\n"},{"id":"150591","messageId":"30770696.248360.1284385078695.JavaMail.root@mail.hq.genarts.com","threadId":"25035","inReplyTo":"201009090117.06555.barra_cuda@katamail.com","subject":"Re: git log for a merged branch","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-09-13T13:37:58Z","receivedAt":"2010-09-13T13:37:58Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"\n\n----- Original Message -----\n> From: \"Michele Ballabio\" <barra_cuda@katamail.com>\n> To: \"Stephen Bash\" <bash@genarts.com>\n> Cc: \"Git Mailing List\" <git@vger.kernel.org>\n> Sent: Wednesday, September 8, 2010 7:17:05 PM\n> Subject: Re: git log for a merged branch\n> On Wednesday 08 September 2010, Stephen Bash wrote:\n>\n> Let's call the merge commit \"mergecmt\". The commit where the \"release\"\n> branch\n> branched off is\n> \n> git merge-base mergecmt^1 mergecmt^2\n> \n> ... where mergecmt^1 is the first parent of the merge (usually on the\n> \"mainline\" branch) and mergecmt^2 is the second parent, which\n> usually(*)\n> refers to the \"release\" branch (in this case, tagFoo).\n> \n> So\n> \n> git log $(git merge-base mergecmt^1 mergecmt^2)..mergecmt^2\n> \n> is what you want.\n> \n> > To complicate things a bit more, in the real world there may be\n> > multiple\n> > merges from the release branch to mainline during the life of the\n> > release\n> > branch, so any solution that also deals with that would be\n> > outstanding\n> > (probably at the cost of additional complexity?)\n> \n> Maybe something like:\n> \n> for i in $(git rev-list --merges last_interesting_tag..mainline)\n> do\n> git log $(git merge-base $i^1 $i^2)..$i^2\n> done\n\nHm...  Makes sense...  I'll have to play with it a little bit to get a good feel for how it fits our workflow, but it seems like a really good option.\n\nThanks!\n\nStephen\n"},{"id":"150593","messageId":"AANLkTikbnoR_=x1_Aq4jh1BuMarEMxXkY=iX0iOjdgyt@mail.gmail.com","threadId":"25035","inReplyTo":"30770696.248360.1284385078695.JavaMail.root@mail.hq.genarts.com","subject":"Re: git log for a merged branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2010-09-13T14:00:18Z","receivedAt":"2010-09-13T14:00:18Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Mon, Sep 13, 2010 at 3:37 PM, Stephen Bash <bash@genarts.com> wrote:\n>\n>\n> ----- Original Message -----\n>> From: \"Michele Ballabio\" <barra_cuda@katamail.com>\n>> To: \"Stephen Bash\" <bash@genarts.com>\n>> Cc: \"Git Mailing List\" <git@vger.kernel.org>\n>> Sent: Wednesday, September 8, 2010 7:17:05 PM\n>> Subject: Re: git log for a merged branch\n>> On Wednesday 08 September 2010, Stephen Bash wrote:\n>>\n>> Let's call the merge commit \"mergecmt\". The commit where the \"release\"\n>> branch\n>> branched off is\n>>\n>> git merge-base mergecmt^1 mergecmt^2\n>>\n>> ... where mergecmt^1 is the first parent of the merge (usually on the\n>> \"mainline\" branch) and mergecmt^2 is the second parent, which\n>> usually(*)\n>> refers to the \"release\" branch (in this case, tagFoo).\n>>\n>> So\n>>\n>> git log $(git merge-base mergecmt^1 mergecmt^2)..mergecmt^2\n>>\n>> is what you want.\n\nIf there is more than one merge-base you´ll have to use:\n\ngit log mergecmt^2 --not $(git merge-base mergecmt^1 mergecmt^2)\n\nand you may use this shorter form:\n\ngit log mergecmt^2 --not $(git merge-base mergecmt^@)\n\nHTH,\nSanti\n"},{"id":"150594","messageId":"15224422.248536.1284387218322.JavaMail.root@mail.hq.genarts.com","threadId":"25035","inReplyTo":"AANLkTikbnoR_=x1_Aq4jh1BuMarEMxXkY=iX0iOjdgyt@mail.gmail.com","subject":"Re: git log for a merged branch","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-09-13T14:13:38Z","receivedAt":"2010-09-13T14:13:38Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"----- Original Message -----\n> From: \"Santi Béjar\" <santi@agolina.net>\n> To: \"Stephen Bash\" <bash@genarts.com>\n> Cc: \"Michele Ballabio\" <barra_cuda@katamail.com>, \"Git Mailing List\" <git@vger.kernel.org>\n> Sent: Monday, September 13, 2010 10:00:18 AM\n> Subject: Re: git log for a merged branch\n> \n> If there is more than one merge-base you´ll have to use:\n> \n> git log mergecmt^2 --not $(git merge-base mergecmt^1 mergecmt^2)\n> \n> and you may use this shorter form:\n> \n> git log mergecmt^2 --not $(git merge-base mergecmt^@)\n\nThat's surprisingly compact...  Impressive.\n\nSlightly changing the topic, we normally tag the release branch, then merge, then delete the branch.  Is there a simple way to determine mergemt from the release tag?\n\nThanks,\nStephen\n"},{"id":"150596","messageId":"AANLkTikw0Cx7aymTxpjRwwxdj0s607eL0creyV5Y+KJQ@mail.gmail.com","threadId":"25035","inReplyTo":"15224422.248536.1284387218322.JavaMail.root@mail.hq.genarts.com","subject":"Re: git log for a merged branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2010-09-13T14:43:59Z","receivedAt":"2010-09-13T14:43:59Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Mon, Sep 13, 2010 at 4:13 PM, Stephen Bash <bash@genarts.com> wrote:\n> ----- Original Message -----\n>> From: \"Santi Béjar\" <santi@agolina.net>\n>> To: \"Stephen Bash\" <bash@genarts.com>\n>> Cc: \"Michele Ballabio\" <barra_cuda@katamail.com>, \"Git Mailing List\" <git@vger.kernel.org>\n>> Sent: Monday, September 13, 2010 10:00:18 AM\n>> Subject: Re: git log for a merged branch\n>>\n>> If there is more than one merge-base you´ll have to use:\n>>\n>> git log mergecmt^2 --not $(git merge-base mergecmt^1 mergecmt^2)\n>>\n>> and you may use this shorter form:\n>>\n>> git log mergecmt^2 --not $(git merge-base mergecmt^@)\n>\n> That's surprisingly compact...  Impressive.\n>\n> Slightly changing the topic, we normally tag the release branch, then merge, then delete the branch.  Is there a simple way to determine mergemt from the release tag?\n\nSo, in other words, you want the list of descendants of the given\nrelease tag say v1.7.3-rc1, contained in a give branch, say \"master\":\n\n$ git rev-list --parents v1.7.3-rc1..master | grep $(git rev-parse\nv1.7.3-rc1^{})\n5418d96ddca8134b5abeb99430f61c062d91f722\n3b3a8ed4beadf5d9437597108355b23c7143bc81\n\nBut note that it may not be unique and may change over time. In\nparticular if you have more commits on top of the tag and merge again.\n\nSanti\n"}]}