{"thread":{"id":"24071","subject":"Porcelain support for daggy-fixes?","startedAt":"2010-06-10T13:55:10Z","lastAt":"2010-06-11T11:25:09Z","messageCount":3,"participants":["Mikko Rantalainen","Pascal Obry"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143437","messageId":"4C10EEBE.5030400@peda.net","threadId":"24071","inReplyTo":null,"subject":"Porcelain support for daggy-fixes?","fromName":"Mikko Rantalainen","fromEmail":"mikko.rantalainen@peda.net","sentAt":"2010-06-10T13:55:10Z","receivedAt":"2010-06-10T13:55:10Z","isPatch":false,"sender":{"key":"mikko.rantalainen@peda.net","avatar":"https://gravatar.com/avatar/e2d770957fa98e434c238272a8ee24c02ab5766ad140c18b9591045c0a49be58?d=mp&s=160"},"body":"Introduction: http://monotone.ca/wiki/DaggyFixes/\n\nI understand that this can already be done with git. The method is\n\n1) store the current HEAD somewhere\n2) figure out the proper parent for the bug fix\n3) checkout the parent\n4) implement the fix\n5) commit the fix\n6) checkout HEAD\n7) merge with the commit from step 5\n\nIs there some way to do this more automatically? The way I think this\nshould be done:\n\n1) fix a bug that you just found (let's imagine for a second that you\njust happened to know how to fix the bug without knowing the history of bug)\n2) git commit (the bugfix is now the tip of the HEAD)\n3) git daggy-fix\n\nAnd you're done.\n\nHere the magical \"daggy-fix\" would do the following:\n\n\"Remove\" the change HEAD^..HEAD from the current branch, try to\nrecursively apply the patch to ancestors of HEAD and locate oldest\nparent that the patch can be automatically applied to without a\nconflict. Let's call this parent BUG (best guess for the original commit\nthat introduced the bug). Commit the patch as a new child of BUG and\nthen merge with HEAD^ (from the moment daggy-fix was executed). Checkout\nthe new HEAD to replace the original HEAD.\n\nIn short, replace the current tip of the current branch with the merge\nof last commit rebased as the bugfix for historical commit and HEAD^.\n\nLogical syntax for this command could be\n\ngit daggy-fix fix-commit-id bug-commit-id\n\nwhere\nfix-commit-id is the commit that should be relocated and re-merged\nbug-commit-id is the commit that introduced the bug (no need for\nautomatic detection of the parent)\n\nboth commit id's are optional.\n\nDoes this sound reasonable or is there already some better way?\n\n-- \nMikko\n"},{"id":"143438","messageId":"AANLkTikbe_0GlSkXxiSeIQl0x0tfTYmoI5RuyJPzZioM@mail.gmail.com","threadId":"24071","inReplyTo":"4C10EEBE.5030400@peda.net","subject":"Re: Porcelain support for daggy-fixes?","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2010-06-10T14:21:58Z","receivedAt":"2010-06-10T14:21:58Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Mikko,\n\n> I understand that this can already be done with git. The method is\n>\n> 1) store the current HEAD somewhere\n> 2) figure out the proper parent for the bug fix\n> 3) checkout the parent\n> 4) implement the fix\n> 5) commit the fix\n> 6) checkout HEAD\n> 7) merge with the commit from step 5\n\nI would probably create a topic/fix branch:\n\n1) figure out the proper parent for the bug fix\n2) create the fix branch and move to it\n    $ git co -b fix-feature-whatever parent\n3) implement the fix\n4) commit the fix\n5) checkout HEAD\n6) merge with the commit from step 4\n\nAnd also merge on release branch if needed.\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"143498","messageId":"4C121D15.7030004@peda.net","threadId":"24071","inReplyTo":"AANLkTikbe_0GlSkXxiSeIQl0x0tfTYmoI5RuyJPzZioM@mail.gmail.com","subject":"Re: Porcelain support for daggy-fixes?","fromName":"Mikko Rantalainen","fromEmail":"mikko.rantalainen@peda.net","sentAt":"2010-06-11T11:25:09Z","receivedAt":"2010-06-11T11:25:09Z","isPatch":false,"sender":{"key":"mikko.rantalainen@peda.net","avatar":"https://gravatar.com/avatar/e2d770957fa98e434c238272a8ee24c02ab5766ad140c18b9591045c0a49be58?d=mp&s=160"},"body":"Pascal Obry wrote:\n> I would probably create a topic/fix branch:\n> \n> 1) figure out the proper parent for the bug fix\n> 2) create the fix branch and move to it\n>     $ git co -b fix-feature-whatever parent\n> 3) implement the fix\n> 4) commit the fix\n> 5) checkout HEAD\n> 6) merge with the commit from step 4\n> \n> And also merge on release branch if needed.\n\nOK. I agree with this. The only problem is step 1 above (plus the other\nrepeated steps if this is done every time you find a bug).\n\nI'm still wondering if it would be possible to figure the correct parent\nautomatically. How about the following:\n\nGiven: minimal patch to fix a bug committed to tip of the master.\nTarget: find proper parent for daggy-fix for the given bugfix (and then\nlater rewrite history to put the fix as daggy-fix and merge with the master)\n\nIdea:\n\nCompare the list of removed lines from latest commit (the bugfix) with\nthe output of the same lines from git blame --cc (immediately before the\nbugfix). Proper parent for the bug fix is the commit that is newest for\nany removed line from the parent of the bugfix in the tip of the master\n(HEAD^).\n\nDoes it sound sensible to assume that the proper parent for the bug fix\nis the newest commit that has modified any line that is removed or\nreplaced by the bug fix?\n\n\nWhy do I even think about this? I believe that daggy-fix style would be\nbeneficial for many software projects but for small fixes it requires\nmany little steps to implement and extra work to figure out the correct\nparent. Small bugs are often easy to fix at the tip of the master so the\nfixes usually end up there. It would be awesome if git were smart enough\nto move the fix to the correct location (daggy-fix)  and do automatic\nmerge, once told that the last commit was really a bugfix. If this ends\nup working well enough, then it should be a flag for commit (--bugfix)\nwhich does the commit to proper parent and then does another merge\ncommit with the current branch. Then the other branches (or forks) could\nmerge the fix more easily (daggy-fixes should merge without conflicts if\ndone correctly).\n\n-- \nMikko\n\n\n"}]}