{"thread":{"id":"42671","subject":"How to find commits unique to a branch","startedAt":"2016-06-20T20:52:31Z","lastAt":"2016-06-22T18:20:37Z","messageCount":9,"participants":["Nikolaus Rath","Junio C Hamano","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"289705","messageId":"878txz8ubq.fsf@thinkpad.rath.org","threadId":"42671","inReplyTo":null,"subject":"How to find commits unique to a branch","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-06-20T20:43:37Z","receivedAt":"2016-06-20T20:52:31Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"Hello,\n\nWhat's the best way to find all commits in a branch A that have not been\ncherry-picked from (or to) another branch B?\n\nI think I could format-patch all commits in every branch into separate\nfiles, hash the Author and Date of each files, and then compare the two\nlists. But I'm hoping there's a way to instead have git do the\nheavy-lifting?\n\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"289715","messageId":"xmqqtwgnsdr3.fsf@gitster.mtv.corp.google.com","threadId":"42671","inReplyTo":"878txz8ubq.fsf@thinkpad.rath.org","subject":"Re: How to find commits unique to a branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-20T22:21:20Z","receivedAt":"2016-06-20T22:22:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nikolaus Rath <Nikolaus@rath.org> writes:\n\n> What's the best way to find all commits in a branch A that have not been\n> cherry-picked from (or to) another branch B?\n>\n> I think I could format-patch all commits in every branch into separate\n> files, hash the Author and Date of each files, and then compare the two\n> lists. But I'm hoping there's a way to instead have git do the\n> heavy-lifting?\n\n\"git cherry\" perhaps?\n\n"},{"id":"289719","messageId":"87lh1z78fr.fsf@thinkpad.rath.org","threadId":"42671","inReplyTo":"xmqqtwgnsdr3.fsf@gitster.mtv.corp.google.com","subject":"Re: How to find commits unique to a branch","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-06-20T23:21:44Z","receivedAt":"2016-06-20T23:21:55Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n> Nikolaus Rath <Nikolaus@rath.org> writes:\n>\n>> What's the best way to find all commits in a branch A that have not been\n>> cherry-picked from (or to) another branch B?\n>>\n>> I think I could format-patch all commits in every branch into separate\n>> files, hash the Author and Date of each files, and then compare the two\n>> lists. But I'm hoping there's a way to instead have git do the\n>> heavy-lifting?\n>\n> \"git cherry\" perhaps?\n\nThat seems to work only the \"wrong way around\". I have a tag\nfuse_3_0_start, which is the common ancestor to \"master\" and\n\"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\nto master that have not been cherry-picked into fuse_2_9_bugfix.\n\nHowever:\n\n* \"git cherry fuse_3_0_start master release2.9\" tells me nothing has\n  been cherry-picked at all (only lines with +)\n\n* \"git cherry fuse_3_0_start release2.9 master\" also tells me nothing\n  has been cherry picked, but somehow shows a smaller total number of\n  commits.\n\n* \"git cherry master release2.9 fuse_3_0_start\" gives me the commits\n  from fuse_2_9_bugfix that have not been cherry-picked into master\n  (which seems to be in contradiction to the two earlier commands).\n\n\nAm I missing something obvious?\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"289735","messageId":"8a97003e-fa74-2d9b-f2a8-946614be649c@drmicha.warpmail.net","threadId":"42671","inReplyTo":"87lh1z78fr.fsf@thinkpad.rath.org","subject":"Re: How to find commits unique to a branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2016-06-21T08:28:53Z","receivedAt":"2016-06-21T08:30:49Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Nikolaus Rath venit, vidit, dixit 21.06.2016 01:21:\n> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>> Nikolaus Rath <Nikolaus@rath.org> writes:\n>>\n>>> What's the best way to find all commits in a branch A that have not been\n>>> cherry-picked from (or to) another branch B?\n>>>\n>>> I think I could format-patch all commits in every branch into separate\n>>> files, hash the Author and Date of each files, and then compare the two\n>>> lists. But I'm hoping there's a way to instead have git do the\n>>> heavy-lifting?\n>>\n>> \"git cherry\" perhaps?\n> \n> That seems to work only the \"wrong way around\". I have a tag\n> fuse_3_0_start, which is the common ancestor to \"master\" and\n> \"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\n> to master that have not been cherry-picked into fuse_2_9_bugfix.\n> \n> However:\n> \n> * \"git cherry fuse_3_0_start master release2.9\" tells me nothing has\n>   been cherry-picked at all (only lines with +)\n> \n> * \"git cherry fuse_3_0_start release2.9 master\" also tells me nothing\n>   has been cherry picked, but somehow shows a smaller total number of\n>   commits.\n> \n> * \"git cherry master release2.9 fuse_3_0_start\" gives me the commits\n>   from fuse_2_9_bugfix that have not been cherry-picked into master\n>   (which seems to be in contradiction to the two earlier commands).\n> \n> \n> Am I missing something obvious?\n\nThere is always\n\ngit log --left-right --cherry-mark A...B\n\nto give you a good overview of the situation.\n\n\"--cherry-pick\" instead of \"--cherry-mark\" will leave out the\n\"=\"-commits (equivalent ones), and the description of \"git log --cherry\"\nin the log man page gives you a good idea of how you can combine\n\"--cherry-pick\" with \"--left-only\" etc. to give you exactly what you want.\n\nFor script-usage, you can finally replace \"git log\" by \"git rev-list\"\nwith the same rev selecting options.\n\nMichael\n\n"},{"id":"289788","messageId":"87oa6ubeq4.fsf@thinkpad.rath.org","threadId":"42671","inReplyTo":"87lh1z78fr.fsf@thinkpad.rath.org","subject":"Re: How to find commits unique to a branch","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-06-21T18:04:35Z","receivedAt":"2016-06-21T18:05:01Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"On Jun 20 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:\n> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>> Nikolaus Rath <Nikolaus@rath.org> writes:\n>>\n>>> What's the best way to find all commits in a branch A that have not been\n>>> cherry-picked from (or to) another branch B?\n>>>\n>>> I think I could format-patch all commits in every branch into separate\n>>> files, hash the Author and Date of each files, and then compare the two\n>>> lists. But I'm hoping there's a way to instead have git do the\n>>> heavy-lifting?\n>>\n>> \"git cherry\" perhaps?\n>\n> That seems to work only the \"wrong way around\". I have a tag\n> fuse_3_0_start, which is the common ancestor to \"master\" and\n> \"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\n> to master that have not been cherry-picked into fuse_2_9_bugfix.\n>\n> However:\n>\n> * \"git cherry fuse_3_0_start master release2.9\" tells me nothing has\n>   been cherry-picked at all (only lines with +)\n>\n> * \"git cherry fuse_3_0_start release2.9 master\" also tells me nothing\n>   has been cherry picked, but somehow shows a smaller total number of\n>   commits.\n>\n> * \"git cherry master release2.9 fuse_3_0_start\" gives me the commits\n>   from fuse_2_9_bugfix that have not been cherry-picked into master\n>   (which seems to be in contradiction to the two earlier commands).\n>\n>\n> Am I missing something obvious?\n\nI meant to add: the repository I'm working with is at\nhttps://github.com/libfuse/libfuse/.\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"289795","messageId":"xmqq7fdiqtqv.fsf@gitster.mtv.corp.google.com","threadId":"42671","inReplyTo":"87oa6ubeq4.fsf@thinkpad.rath.org","subject":"Re: How to find commits unique to a branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-21T18:31:04Z","receivedAt":"2016-06-21T18:44:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nikolaus Rath <Nikolaus@rath.org> writes:\n\n> On Jun 20 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:\n>> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Nikolaus Rath <Nikolaus@rath.org> writes:\n>>>\n>>>> What's the best way to find all commits in a branch A that have not been\n>>>> cherry-picked from (or to) another branch B?\n>>>>\n>>>> I think I could format-patch all commits in every branch into separate\n>>>> files, hash the Author and Date of each files, and then compare the two\n>>>> lists. But I'm hoping there's a way to instead have git do the\n>>>> heavy-lifting?\n>>>\n>>> \"git cherry\" perhaps?\n>>\n>> That seems to work only the \"wrong way around\". I have a tag\n>> fuse_3_0_start, which is the common ancestor to \"master\" and\n>> \"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\n>> to master that have not been cherry-picked into fuse_2_9_bugfix.\n\nHmm, so the topology roughly would look like:\n\n            A'--B'--D' 2fix\n           /\n          o---A---B---C---D---E---F master\n\t3start\n\nAnd you want to find commits in 3start..master that do not have\nequivalent in 3start..2fix\n\n\"git cherry --help\" starts like this:\n\n    NAME\n           git-cherry - Find commits yet to be applied to upstream\n\n    SYNOPSIS\n           git cherry [-v] [<upstream> [<head> [<limit>]]]\n\n    DESCRIPTION\n           Determine whether there are commits in <head>..<upstream>\n           that are equivalent to those in the range <limit>..<head>.\n\nApplying that to our picture, we want to find commits yet to be\napplied to 2fix, and do so by comparing the commits between\n3start..master and 3start..2fix.\n\nI find that the first sentence of the description is fuzzy\n(\"Determine whether\" would imply that you would get \"Yes/No\" but\nwhat we want is \"here are the commits that do not have counterpart\nin 2fix\"), but we already know <upstream> corresponds to 2fix\n(i.e. we are finding ones yet to be applied to there, which can be\ninferred from the NAME line), so <head> must be 'master' That means\nthat <limit> corresponds to 3start, and we will be comparing commits\nin two ranges:\n\n    master..2fix (i e. <head>..<upstream>, which is the same thing as 3start..2fix)\n    3start..master (i.e. <limit>..<head>)\n\nSo perhaps \"git cherry -v 2fix master 3start\"?\n"},{"id":"289862","messageId":"87mvmdgowj.fsf@thinkpad.rath.org","threadId":"42671","inReplyTo":"xmqq7fdiqtqv.fsf@gitster.mtv.corp.google.com","subject":"Re: How to find commits unique to a branch","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-06-22T16:38:04Z","receivedAt":"2016-06-22T16:38:11Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"On Jun 21 2016, Junio C Hamano <gitster@pobox.com> wrote:\n> Nikolaus Rath <Nikolaus@rath.org> writes:\n>\n>> On Jun 20 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:\n>>> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>>>> Nikolaus Rath <Nikolaus@rath.org> writes:\n>>>>\n>>>>> What's the best way to find all commits in a branch A that have not been\n>>>>> cherry-picked from (or to) another branch B?\n>>>>>\n>>>>> I think I could format-patch all commits in every branch into separate\n>>>>> files, hash the Author and Date of each files, and then compare the two\n>>>>> lists. But I'm hoping there's a way to instead have git do the\n>>>>> heavy-lifting?\n>>>>\n>>>> \"git cherry\" perhaps?\n>>>\n>>> That seems to work only the \"wrong way around\". I have a tag\n>>> fuse_3_0_start, which is the common ancestor to \"master\" and\n>>> \"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\n>>> to master that have not been cherry-picked into fuse_2_9_bugfix.\n>\n> Hmm, so the topology roughly would look like:\n>\n>             A'--B'--D' 2fix\n>            /\n>           o---A---B---C---D---E---F master\n> \t3start\n>\n> And you want to find commits in 3start..master that do not have\n> equivalent in 3start..2fix\n>\n> \"git cherry --help\" starts like this:\n>\n>     NAME\n>            git-cherry - Find commits yet to be applied to upstream\n>\n>     SYNOPSIS\n>            git cherry [-v] [<upstream> [<head> [<limit>]]]\n>\n>     DESCRIPTION\n>            Determine whether there are commits in <head>..<upstream>\n>            that are equivalent to those in the range <limit>..<head>.\n>\n> Applying that to our picture, we want to find commits yet to be\n> applied to 2fix, and do so by comparing the commits between\n> 3start..master and 3start..2fix.\n>\n> I find that the first sentence of the description is fuzzy\n> (\"Determine whether\" would imply that you would get \"Yes/No\" but\n> what we want is \"here are the commits that do not have counterpart\n> in 2fix\"), but we already know <upstream> corresponds to 2fix\n> (i.e. we are finding ones yet to be applied to there, which can be\n> inferred from the NAME line), so <head> must be 'master' That means\n> that <limit> corresponds to 3start, and we will be comparing commits\n> in two ranges:\n>\n>     master..2fix (i e. <head>..<upstream>, which is the same thing as 3start..2fix)\n>     3start..master (i.e. <limit>..<head>)\n>\n> So perhaps \"git cherry -v 2fix master 3start\"?\n\nThis works, thanks! I don't quite understand why though. I started by\nsaying that I want to know which commits in master are have been cherry\npicked after 3start was branched to 2fix, so <limit>..<head> must be\n3start..2fix, which only leaves \"master\" as <upstream>.  What's wrong\nwith that thought?\n\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"289863","messageId":"87k2hhgow0.fsf@thinkpad.rath.org","threadId":"42671","inReplyTo":"8a97003e-fa74-2d9b-f2a8-946614be649c@drmicha.warpmail.net","subject":"Re: How to find commits unique to a branch","fromName":"Nikolaus Rath","fromEmail":"nikolaus@rath.org","sentAt":"2016-06-22T16:38:23Z","receivedAt":"2016-06-22T16:38:27Z","isPatch":false,"sender":{"key":"nikolaus@rath.org","avatar":"https://gravatar.com/avatar/d3b6cdc023a0665882d5aac373c0115bcb36f730c2e4a4051061fefbaf7dd041?d=mp&s=160"},"body":"On Jun 21 2016, Michael J Gruber <git@drmicha.warpmail.net> wrote:\n> Nikolaus Rath venit, vidit, dixit 21.06.2016 01:21:\n>> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Nikolaus Rath <Nikolaus@rath.org> writes:\n>>>\n>>>> What's the best way to find all commits in a branch A that have not been\n>>>> cherry-picked from (or to) another branch B?\n>>>>\n>>>> I think I could format-patch all commits in every branch into separate\n>>>> files, hash the Author and Date of each files, and then compare the two\n>>>> lists. But I'm hoping there's a way to instead have git do the\n>>>> heavy-lifting?\n>>>\n>>> \"git cherry\" perhaps?\n>> \n>> That seems to work only the \"wrong way around\". I have a tag\n>> fuse_3_0_start, which is the common ancestor to \"master\" and\n>> \"fuse_2_9_bugfix\". I'd like to find all the commits from fuse_3_0_start\n>> to master that have not been cherry-picked into fuse_2_9_bugfix.\n>> \n>> However:\n>> \n>> * \"git cherry fuse_3_0_start master release2.9\" tells me nothing has\n>>   been cherry-picked at all (only lines with +)\n>> \n>> * \"git cherry fuse_3_0_start release2.9 master\" also tells me nothing\n>>   has been cherry picked, but somehow shows a smaller total number of\n>>   commits.\n>> \n>> * \"git cherry master release2.9 fuse_3_0_start\" gives me the commits\n>>   from fuse_2_9_bugfix that have not been cherry-picked into master\n>>   (which seems to be in contradiction to the two earlier commands).\n>> \n>> \n>> Am I missing something obvious?\n>\n> There is always\n>\n> git log --left-right --cherry-mark A...B\n>\n> to give you a good overview of the situation.\n\nThis worked nicely too, thanks!\n\nBest,\n-Nikolaus\n\n-- \nGPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F\nFingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F\n\n             »Time flies like an arrow, fruit flies like a Banana.«\n"},{"id":"289878","messageId":"xmqqh9clm6fl.fsf@gitster.mtv.corp.google.com","threadId":"42671","inReplyTo":"87mvmdgowj.fsf@thinkpad.rath.org","subject":"Re: How to find commits unique to a branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-22T18:20:30Z","receivedAt":"2016-06-22T18:20:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nikolaus Rath <Nikolaus@rath.org> writes:\n\n> On Jun 21 2016, Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> I find that the first sentence of the description is fuzzy\n>> (\"Determine whether\" would imply that you would get \"Yes/No\" but\n>> what we want is \"here are the commits that do not have counterpart\n>> in 2fix\"),...\n>\n> This works, thanks! I don't quite understand why though. I started by\n> saying that I want to know which commits in master are have been cherry\n> picked after 3start was branched to 2fix, so <limit>..<head> must be\n> 3start..2fix, which only leaves \"master\" as <upstream>.  What's wrong\n> with that thought?\n\nThe only thing that is wrong in that is it does not match what\nhappens, but that is not the fault of the \"thought\"; as I said, I\nthink the description is fuzzy and has room for improvement to avoid\nbeing read in such a way that leads to a wrong conclusion.\n"}]}