{"thread":{"id":"24200","subject":"How to manage merges from one line while excluding its merges from another","startedAt":"2010-06-25T22:26:36Z","lastAt":"2010-06-26T00:51:52Z","messageCount":4,"participants":["Lane Brooks","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144271","messageId":"4C252D1C.4010702@brooks.nu","threadId":"24200","inReplyTo":null,"subject":"How to manage merges from one line while excluding its merges from another","fromName":"Lane Brooks","fromEmail":"lane@brooks.nu","sentAt":"2010-06-25T22:26:36Z","receivedAt":"2010-06-25T22:26:36Z","isPatch":false,"sender":{"key":"lane@brooks.nu","avatar":null},"body":"I have a tree like this:\n\n      G---H---I---J---K   devel\n     /       /       /\nA---B---C---D---E---F    main\n         \\\n          L---M---N---O   my\n\n\nThe 'my' branch forked off the 'main' line and for reasons out of my \ncontrol cannot merge the 'main' changes (D,E,F) back.\n\nThe 'devel' line is a another line that I need to track and merge from, \nbut I only want the changes local to that branch that are not on from \nthe mainline. i.e., I only want commits G,H,J.\n\nI want to continue to merge from the devel line as additional commits\nare made that are not on the main branch, but I do not want any of the \nfuture merge commits.\n\nIs there an automated way to do this or do I have to cherry pick \neverything by hand?\n\nThanks,\nLane\n"},{"id":"144280","messageId":"20100626000358.GA11473@burratino","threadId":"24200","inReplyTo":"4C252D1C.4010702@brooks.nu","subject":"Re: How to manage merges from one line while excluding its merges from another","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T00:03:58Z","receivedAt":"2010-06-26T00:03:58Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Lane,\n\nLane Brooks wrote:\n\n> I have a tree like this:\n> \n>      G---H---I---J---K   devel\n>     /       /       /\n> A---B---C---D---E---F    main\n>         \\\n>          L---M---N---O   my\n\nNice diagram.\n\nWhat is missing is a picture of what you want the result to be.\n\n> The 'my' branch forked off the 'main' line and for reasons out of my\n> control cannot merge the 'main' changes (D,E,F) back.\n[...]\n> I want to continue to merge from the devel line as additional commits\n> are made that are not on the main branch, but I do not want any of\n> the future merge commits.\n\n(I) I am guessing that the 'main' line is not part of the published\nhistory, in which case you what you want might look like this:\n\n         ... devel\n      /\n A---B---C- ... main\n          \\\n           L---M---N---O---H'---J' my\n\nThe J commit itself could not be included in the history of the 'my'\nbranch because its ancestor D is not meant to be published.\n\n(II) In an alternative scenario, the 'main' changes (D, E, F) are\nforbidden because they introduce bugs.  In this case, a solution might\nlook something like this:\n\n       ...                  K devel\n     /               /       \\\nA---B---C---D---E---F main    \\\n         \\                     \\\n          L---M---N---O---------P---Q---R---S\n\nwhere Q, R, and S are commits (created with ‘git revert’) that\nundo the effect of F, E, and D.  From then on, you can just merge\nfrom devel as usual.\n\n> Is there an automated way to do this or do I have to cherry pick\n> everything by hand?\n\nIn git 1.7.2, you will be able to automate (I) as follows:\n\n git cherry-pick --no-merges ^my ^main devel\n\nUntil then, you might want to try experimenting with something\nlike this:\n\n git rev-list --no-merges ^my ^main devel |\n while read rev\n do\n\tgit cherry-pick $rev ||\n\t{\n\t\techo >&2 cherry-pick failed\n\t\tbreak\n\t}\n done\n\nHope that helps,\nJonathan\n"},{"id":"144281","messageId":"4C254B62.6020108@brooks.nu","threadId":"24200","inReplyTo":"20100626000358.GA11473@burratino","subject":"Re: How to manage merges from one line while excluding its merges from another","fromName":"Lane Brooks","fromEmail":"lane@brooks.nu","sentAt":"2010-06-26T00:35:46Z","receivedAt":"2010-06-26T00:35:46Z","isPatch":false,"sender":{"key":"lane@brooks.nu","avatar":null},"body":"On 06/25/2010 06:03 PM, Jonathan Nieder wrote:\n> Hi Lane,\n>\n> Lane Brooks wrote:\n>\n>    \n>> I have a tree like this:\n>>\n>>       G---H---I---J---K   devel\n>>      /       /       /\n>> A---B---C---D---E---F    main\n>>          \\\n>>           L---M---N---O   my\n>>      \n> Nice diagram.\n>\n> What is missing is a picture of what you want the result to be.\n>\n>    \n>> The 'my' branch forked off the 'main' line and for reasons out of my\n>> control cannot merge the 'main' changes (D,E,F) back.\n>>      \n> [...]\n>    \n>> I want to continue to merge from the devel line as additional commits\n>> are made that are not on the main branch, but I do not want any of\n>> the future merge commits.\n>>      \n> (I) I am guessing that the 'main' line is not part of the published\n> history, in which case you what you want might look like this:\n>\n>           ... devel\n>        /\n>   A---B---C- ... main\n>            \\\n>             L---M---N---O---H'---J' my\n>\n> The J commit itself could not be included in the history of the 'my'\n> branch because its ancestor D is not meant to be published.\n>\n> (II) In an alternative scenario, the 'main' changes (D, E, F) are\n> forbidden because they introduce bugs.  In this case, a solution might\n> look something like this:\n>\n>         ...                  K devel\n>       /               /       \\\n> A---B---C---D---E---F main    \\\n>           \\                     \\\n>            L---M---N---O---------P---Q---R---S\n>\n> where Q, R, and S are commits (created with ‘git revert’) that\n> undo the effect of F, E, and D.  From then on, you can just merge\n> from devel as usual.\n>\n>    \n>> Is there an automated way to do this or do I have to cherry pick\n>> everything by hand?\n>>      \n> In git 1.7.2, you will be able to automate (I) as follows:\n>\n>   git cherry-pick --no-merges ^my ^main devel\n>\n> Until then, you might want to try experimenting with something\n> like this:\n>\n>   git rev-list --no-merges ^my ^main devel |\n>   while read rev\n>   do\n> \tgit cherry-pick $rev ||\n> \t{\n> \t\techo>&2 cherry-pick failed\n> \t\tbreak\n> \t}\n>   done\n>\n> Hope that helps,\n> Jonathan\n>    \nI guess (I) is what I want, but your enumerating those two options makes \nme wonder how well things will go when 'devel' and 'main' merge and then \n'my' needs to merge in from 'main'. Seems like a disaster waiting to happen.\n\nI'll take a look at your suggested cherry-pick script. Can it be rerun \nmultiple times or is it run one-time only. In others, as 'devel' \ncontinues to grow can I run it again and will it cherry-pick \nintelligently or will it try to reapply commits already cherry-picked?\n\nThanks,\nLane\n"},{"id":"144282","messageId":"20100626005151.GA12401@burratino","threadId":"24200","inReplyTo":"4C254B62.6020108@brooks.nu","subject":"Re: How to manage merges from one line while excluding its merges from another","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T00:51:52Z","receivedAt":"2010-06-26T00:51:52Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Lane Brooks wrote:\n\n> I'll take a look at your suggested cherry-pick script. Can it be\n> rerun multiple times or is it run one-time only. In others, as\n> 'devel' continues to grow can I run it again and will it cherry-pick\n> intelligently or will it try to reapply commits already\n> cherry-picked?\n\nGood point.\n\n  git cherry my devel main |\n  grep -v ^- |\n  while read mark rev\n  do\n\tgit cherry-pick $rev ||\n\t{\n\t\techo >&2 cherry-pick failed\n\t\tbreak\n\t}\n done\n\nI hadn’t known about the third argument to ‘git cherry’ before.\nThanks for the example.\n"}]}