{"thread":{"id":"23674","subject":"WANTED: patch splitting tool - waypoints","startedAt":"2010-05-02T11:58:42Z","lastAt":"2010-05-03T06:43:18Z","messageCount":7,"participants":["Bron Gondwana","Matthieu Moy","Robin Rosenberg","Yann Dirson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"140761","messageId":"20100502115842.GA11607@brong.net","threadId":"23674","inReplyTo":null,"subject":"WANTED: patch splitting tool - waypoints","fromName":"Bron Gondwana","fromEmail":"brong@brong.net","sentAt":"2010-05-02T11:58:42Z","receivedAt":"2010-05-02T11:58:42Z","isPatch":false,"sender":{"key":"brong@brong.net","avatar":null},"body":"Hi,\n\nMy toolkit is missing a tool.  I've never seen it\nor anything like it, but I can describe it - and\nhopefully someone else knows if it exists.\n\nIt's basically a combination of git rebase -i and\ngit add -p.  Something that allows you to split\neither a single patch or a series of patches that\nhad bad \"waypoints\".\n\nYou can imagine the patch as a journey from A to B.\nOnly, that's a long journey, and the path between\nthem is a big ugly code dump.  The commits along\nthe way include various adventures down rabbit holes\nthat got backed out much later without necessarily\ntidying up the history along the way.\n\nThis tool allows you to easily generate one\nintermediate state.  Repeated application generates\nmultiple intermediate states until you have a nice\ntidy patch series, every step of the way bisectable.\n\nSo the journey A => B becomes the journey A => W => B.\n\nThe tool allows you to quickly choose which hunks to\nadd to patch(A=>W) and which to add to patch(W=>B),\nbut also lets you make edits to the intermediate state\neasily so that W will compile even if some bits of the\npatch were intermingled.\n\n\nDoes anybody know of a tool that can do this?  Does it\nsounds like something others would use?  I'm thinking\nthat you could sort of get there with a combination of\nrebase squash, git add -p and a git stash holding the\nstate of 'B', but it would need to be scripted enough\nthat repeated application isn't a pain.  And a graphical/\nncurses interface like the kernel's \"make menuconfig\" at\nthe very least would make it much easier than paging\nthrough piles of diff fragments and hoping you never\nmade a mistake.\n\nRegards,\n\nBron.\n"},{"id":"140776","messageId":"vpqwrvmuycy.fsf@bauges.imag.fr","threadId":"23674","inReplyTo":"20100502115842.GA11607@brong.net","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-05-02T15:17:33Z","receivedAt":"2010-05-02T15:17:33Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Bron Gondwana <brong@brong.net> writes:\n\n> Hi,\n>\n> My toolkit is missing a tool.  I've never seen it\n> or anything like it, but I can describe it - and\n> hopefully someone else knows if it exists.\n>\n> It's basically a combination of git rebase -i and\n> git add -p.\n\nI guess you named it: git add -p.\n\n> So the journey A => B becomes the journey A => W => B.\n\nJust checkout B, then\n\ngit reset HEAD^\n\nThis will reset your _index_ to the state of A (which happens to be\nHEAD^, the ancestor of HEAD). Now, you can\n\nwhile !happy; do\n    git add -p   # select patch hunks\n    git commit   # Create an intermediate commit\ndone\ngit commit -a    # Re-create commit B\n\n> The tool allows you to quickly choose which hunks to\n> add to patch(A=>W) and which to add to patch(W=>B),\n> but also lets you make edits to the intermediate state\n> easily so that W will compile even if some bits of the\n> patch were intermingled.\n\nThen, \"git stash --keep-index\" between \"git add -p\" and \"git commit\",\nand \"git stash pop\" afterwards.\n\n> And a graphical/\n> ncurses interface\n\nthen, replace \"git add -p; git commit\" with \"git gui\", which will let\nyou select hunks and commit from a GUI.\n\n\nNote that \"rebase -i\" is not strictly needed here, but you can apply\nthe above flow within a \"edit\" command of \"rebase -i\", so it's a nice\ncomplement.\n\n--\nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"140777","messageId":"vpqpr1euy7e.fsf@bauges.imag.fr","threadId":"23674","inReplyTo":"20100502115842.GA11607@brong.net","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-05-02T15:20:53Z","receivedAt":"2010-05-02T15:20:53Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Bron Gondwana <brong@brong.net> writes:\n\n> And a graphical/\n> ncurses interface like the kernel's \"make menuconfig\" at\n> the very least would make it much easier than paging\n> through piles of diff fragments and hoping you never\n> made a mistake.\n\nAbout the \"never made a mistake\" part, if you mistakenly add a hunk\nwith \"git add -p\", then \"git reset -p\" (in recent enough Git's) is\nyour friend.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"140797","messageId":"201005022310.34169.robin.rosenberg@dewire.com","threadId":"23674","inReplyTo":"20100502115842.GA11607@brong.net","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2010-05-02T21:10:33Z","receivedAt":"2010-05-02T21:10:33Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndagen den 2 maj 2010 13.58.42 skrev  Bron Gondwana:\n> Hi,\n> \n> My toolkit is missing a tool.  I've never seen it\n> or anything like it, but I can describe it - and\n> hopefully someone else knows if it exists.\n> \n> It's basically a combination of git rebase -i and\n> git add -p.  Something that allows you to split\n> either a single patch or a series of patches that\n> had bad \"waypoints\".\n> \n> You can imagine the patch as a journey from A to B.\n> Only, that's a long journey, and the path between\n> them is a big ugly code dump.  The commits along\n> the way include various adventures down rabbit holes\n> that got backed out much later without necessarily\n> tidying up the history along the way.\n> \n> This tool allows you to easily generate one\n> intermediate state.  Repeated application generates\n> multiple intermediate states until you have a nice\n> tidy patch series, every step of the way bisectable.\n> \n> So the journey A => B becomes the journey A => W => B.\n> \n> The tool allows you to quickly choose which hunks to\n> add to patch(A=>W) and which to add to patch(W=>B),\n> but also lets you make edits to the intermediate state\n> easily so that W will compile even if some bits of the\n> patch were intermingled.\n> \n> \n> Does anybody know of a tool that can do this?  Does it\n> sounds like something others would use?  I'm thinking\n> that you could sort of get there with a combination of\n> rebase squash, git add -p and a git stash holding the\n> state of 'B', but it would need to be scripted enough\n> that repeated application isn't a pain.  And a graphical/\n> ncurses interface like the kernel's \"make menuconfig\" at\n> the very least would make it much easier than paging\n> through piles of diff fragments and hoping you never\n> made a mistake.\n\nWhat I do is close to what you describe. I use rebase -i and\nedit commits that contain too much using git gui, i.e. I remove\nstuff that do not belong in that commit and ammend the commit.\nThen I commit that extra \"junk\" into a (new) commit and continue.\n\nThe next round with rebase -i I rearrange and squash things. Onviously\nsome junk gets deleted too, though the squashing takes care of most\nof that work.\n\nI have a vision for Eclipse working with the history view (would translate \nwell to any GUI) but when is not in my calendar yet.\n\n-- robin\n"},{"id":"140802","messageId":"20100502234058.GA1818@brong.net","threadId":"23674","inReplyTo":"vpqpr1euy7e.fsf@bauges.imag.fr","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Bron Gondwana","fromEmail":"brong@fastmail.fm","sentAt":"2010-05-02T23:40:58Z","receivedAt":"2010-05-02T23:40:58Z","isPatch":false,"sender":{"key":"brong@fastmail.fm","avatar":"https://gravatar.com/avatar/9b7b59d9f9f104cf348df27c705c0ab5537bd40f291b0adf7885d5d1cea10d00?d=mp&s=160"},"body":"On Sun, May 02, 2010 at 05:20:53PM +0200, Matthieu Moy wrote:\n> Bron Gondwana <brong@brong.net> writes:\n> \n> > And a graphical/\n> > ncurses interface like the kernel's \"make menuconfig\" at\n> > the very least would make it much easier than paging\n> > through piles of diff fragments and hoping you never\n> > made a mistake.\n> \n> About the \"never made a mistake\" part, if you mistakenly add a hunk\n> with \"git add -p\", then \"git reset -p\" (in recent enough Git's) is\n> your friend.\n\nOoh, that's probably the bit that I was missing :)  Excellent.  I'll\nhave a play and see how the workflow feels.\n\nThanks,\n\nBron.\n"},{"id":"140810","messageId":"vpqd3xdlcns.fsf@bauges.imag.fr","threadId":"23674","inReplyTo":"20100502234058.GA1818@brong.net","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-05-03T06:31:03Z","receivedAt":"2010-05-03T06:31:03Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Bron Gondwana <brong@fastmail.fm> writes:\n\n> On Sun, May 02, 2010 at 05:20:53PM +0200, Matthieu Moy wrote:\n>\n>> About the \"never made a mistake\" part, if you mistakenly add a hunk\n>> with \"git add -p\", then \"git reset -p\" (in recent enough Git's) is\n>> your friend.\n>\n> Ooh, that's probably the bit that I was missing :)  Excellent.  I'll\n> have a play and see how the workflow feels.\n\nThere's also \"git stash -p\", which may trigger another smiley ;-).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"140812","messageId":"loom.20100503T082814-180@post.gmane.org","threadId":"23674","inReplyTo":"20100502115842.GA11607@brong.net","subject":"Re: WANTED: patch splitting tool - waypoints","fromName":"Yann Dirson","fromEmail":"yann.dirson@bertin.fr","sentAt":"2010-05-03T06:43:18Z","receivedAt":"2010-05-03T06:43:18Z","isPatch":false,"sender":{"key":"yann.dirson@bertin.fr","avatar":null},"body":"Bron Gondwana <brong <at> brong.net> writes:\n> My toolkit is missing a tool.  I've never seen it\n> or anything like it, but I can describe it - and\n> hopefully someone else knows if it exists.\n> \n> It's basically a combination of git rebase -i and\n> git add -p.  Something that allows you to split\n> either a single patch or a series of patches that\n> had bad \"waypoints\".\n\nRight, this is a use-case I also commonly have, and nowadays I\nmostly use the rebase -i approach already described, combined with\nthe use of git-gui for easy selection.\n\nOne additional trick I sometimes use, when I have reordered/squashed/split\na couple of commits, is things like \"git checkout @{1}\" to catch any missing\nchanges I could have lost while working.\n\nSome time ago I was using stgit extensively, and had developped\na couple of scripts to support that workflow.  You will find them\nin the contrib/ directory of the stgit repo, and in the\nstgit-contrib debian package.  Note that I did not use them much\nlately, and they may need some tweeking to work with recent\ngit/stgit.\n\nThe still-relevant scripts are:\n  * stg-fold-files-from: pick specific hunks from another patch up the stack\n  * stg-dispatch: dispatch specific hunks into another patch down the stack\n"}]}