{"thread":{"id":"30659","subject":"How to find all the commits that comprise a branch?","startedAt":"2012-05-30T17:39:28Z","lastAt":"2012-05-31T12:56:31Z","messageCount":5,"participants":["Felipe Contreras","Junio C Hamano","Sitaram Chamarty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"192500","messageId":"CAMP44s2kEMK8ik2NTiP4uiN4FPWFNYNJfY5qh5QE_hRH2AiNYA@mail.gmail.com","threadId":"30659","inReplyTo":null,"subject":"How to find all the commits that comprise a branch?","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-05-30T17:39:28Z","receivedAt":"2012-05-30T17:39:28Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nBasically what I want to do is:\n\n % git log branch ^<any-other-branch>\n\nIOW; all the commits were 'git branch --contains' would show 'branch'\nand nothing else.\n\nIs there any easy way to do that?\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"192507","messageId":"7vaa0pzcvp.fsf@alter.siamese.dyndns.org","threadId":"30659","inReplyTo":"CAMP44s2kEMK8ik2NTiP4uiN4FPWFNYNJfY5qh5QE_hRH2AiNYA@mail.gmail.com","subject":"Re: How to find all the commits that comprise a branch?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-30T19:29:14Z","receivedAt":"2012-05-30T19:29:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Hi,\n>\n> Basically what I want to do is:\n>\n>  % git log branch ^<any-other-branch>\n>\n> IOW; all the commits were 'git branch --contains' would show 'branch'\n> and nothing else.\n>\n> Is there any easy way to do that?\n\nThere was \"log blah --not --all --exclude-ref=refs/heads/blah\"\ndiscussion a few months ago, but I do not think anything came out of\nit.\n\nThis is a tangent, but it would be a good way to find out set of\ncommits that you would lose and need to go to reflog to find if you\nwere to delete the branch.\n\nIt however is a poor definition for \"commits that comprise a branch\";\nI actually am not sure if the concept has a sensible definition.\n\nLet's think aloud with a few examples.\n\nYou may be done with your \"work\" branch and merge it to \"master\".\nAt that point, do you think you no longer have any commit that\ncomprises your \"work\" branch?\n\nYou could argue that \"work\" branch is no longer relevant because it\nis part of \"master\", and it is an understandable viewpoint.\n\nBut imagine what happens when you find a bug in your \"work\" and want\nto fix it up by queuing a correction on your \"work\" branch (not\ndirectly on \"master\", because your \"work\" branch was forked from\n\"maint\" and you eventually want to merge it there as well).  Now, is\nthe single fix-up commit the only commit that comprises your \"work\"?\n\nSuppose you have 5-patch series in your \"work\" branch, two commits\nat the bottom of which are useful refactoring of existing code.  I\nfork from the second commit to take advantage of your refactoring to\nwork on something entirely different.  These two branches now share\nthe bottom two commits.  At this point, do you have only three\nremaining commits on your \"work\" branch?  Wouldn't we rather want to\nsay that I am merely borrowing two commits from you and you still\nhave 5 commits that is what your \"work\" branch consists of?\n"},{"id":"192508","messageId":"CAMP44s0ZJG1aqe8z-fPfwU+oMNwSh=YjNA6mPiZ+Tdj2eBgpKQ@mail.gmail.com","threadId":"30659","inReplyTo":"7vaa0pzcvp.fsf@alter.siamese.dyndns.org","subject":"Re: How to find all the commits that comprise a branch?","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-05-30T20:23:03Z","receivedAt":"2012-05-30T20:23:03Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, May 30, 2012 at 9:29 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> Hi,\n>>\n>> Basically what I want to do is:\n>>\n>>  % git log branch ^<any-other-branch>\n>>\n>> IOW; all the commits were 'git branch --contains' would show 'branch'\n>> and nothing else.\n>>\n>> Is there any easy way to do that?\n>\n> There was \"log blah --not --all --exclude-ref=refs/heads/blah\"\n> discussion a few months ago, but I do not think anything came out of\n> it.\n>\n> This is a tangent, but it would be a good way to find out set of\n> commits that you would lose and need to go to reflog to find if you\n> were to delete the branch.\n>\n> It however is a poor definition for \"commits that comprise a branch\";\n> I actually am not sure if the concept has a sensible definition.\n>\n> Let's think aloud with a few examples.\n>\n> You may be done with your \"work\" branch and merge it to \"master\".\n> At that point, do you think you no longer have any commit that\n> comprises your \"work\" branch?\n\nThat's right... no commits.\n\n> You could argue that \"work\" branch is no longer relevant because it\n> is part of \"master\", and it is an understandable viewpoint.\n>\n> But imagine what happens when you find a bug in your \"work\" and want\n> to fix it up by queuing a correction on your \"work\" branch (not\n> directly on \"master\", because your \"work\" branch was forked from\n> \"maint\" and you eventually want to merge it there as well).  Now, is\n> the single fix-up commit the only commit that comprises your \"work\"?\n\nYes. On that branch.\n\n> Suppose you have 5-patch series in your \"work\" branch, two commits\n> at the bottom of which are useful refactoring of existing code.  I\n> fork from the second commit to take advantage of your refactoring to\n> work on something entirely different.  These two branches now share\n> the bottom two commits.  At this point, do you have only three\n> remaining commits on your \"work\" branch?  Wouldn't we rather want to\n> say that I am merely borrowing two commits from you and you still\n> have 5 commits that is what your \"work\" branch consists of?\n\nIt depends; if your branch gets merged to master, then my work branch\nis comprised of 3 commits.\n\nOf course it's debatable how to consider the commits that are\ncontained in multiple branches, but it's clear that the commits that\nare only in one branch comprise that branch.\n\nEither way, call them 'independent' or whatever you want, but the\nconcept of \"commits that are only in one branch\" is clear, and it's\nuseful to find this information.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"192533","messageId":"CAMK1S_i5-ALrMA+iJ1Q4R5FuVbjVdFLfxKoEF4BVHERHSzmjeg@mail.gmail.com","threadId":"30659","inReplyTo":"CAMP44s2kEMK8ik2NTiP4uiN4FPWFNYNJfY5qh5QE_hRH2AiNYA@mail.gmail.com","subject":"Re: How to find all the commits that comprise a branch?","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2012-05-31T03:22:12Z","receivedAt":"2012-05-31T03:22:12Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Wed, May 30, 2012 at 11:09 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> Hi,\n>\n> Basically what I want to do is:\n>\n>  % git log branch ^<any-other-branch>\n>\n> IOW; all the commits were 'git branch --contains' would show 'branch'\n> and nothing else.\n\nI have a script called \"otb\" (only this branch, I guess; I tend to use\ncrappily short names for stuff I don't make public!) that looks like\nthis:\n\n#!/bin/bash\n\nm=$(git rev-parse HEAD)\nn=$(git rev-parse --branches | grep -v $m)\ngit log --oneline $m --not $n\n\nI think that fits your description, but it's not *one* command.\n\n> Is there any easy way to do that?\n>\n> Cheers.\n>\n> --\n> Felipe Contreras\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\n\n-- \nSitaram\n"},{"id":"192562","messageId":"CAMP44s3Fn3nai3TqCpYRxyV=3=d3vm5aPd-VgZWpVXb4qC8W8Q@mail.gmail.com","threadId":"30659","inReplyTo":"CAMK1S_i5-ALrMA+iJ1Q4R5FuVbjVdFLfxKoEF4BVHERHSzmjeg@mail.gmail.com","subject":"Re: How to find all the commits that comprise a branch?","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-05-31T12:56:31Z","receivedAt":"2012-05-31T12:56:31Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, May 31, 2012 at 5:22 AM, Sitaram Chamarty <sitaramc@gmail.com> wrote:\n> On Wed, May 30, 2012 at 11:09 PM, Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n>> Hi,\n>>\n>> Basically what I want to do is:\n>>\n>>  % git log branch ^<any-other-branch>\n>>\n>> IOW; all the commits were 'git branch --contains' would show 'branch'\n>> and nothing else.\n>\n> I have a script called \"otb\" (only this branch, I guess; I tend to use\n> crappily short names for stuff I don't make public!) that looks like\n> this:\n>\n> #!/bin/bash\n>\n> m=$(git rev-parse HEAD)\n> n=$(git rev-parse --branches | grep -v $m)\n> git log --oneline $m --not $n\n>\n> I think that fits your description, but it's not *one* command.\n\nYeap, I was thinking on doing something along those lines... but hoped\nthere was a single command for it.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}