{"thread":{"id":"39428","subject":"Staging commits with visual diff tools?","startedAt":"2015-05-26T20:50:49Z","lastAt":"2015-06-28T17:56:58Z","messageCount":10,"participants":["John Lee","Jeff King","Michael J Gruber","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"262159","messageId":"alpine.DEB.2.10.1505262147230.3709@alice","threadId":"39428","inReplyTo":null,"subject":"Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-05-26T20:50:49Z","receivedAt":"2015-05-26T20:50:49Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"Hi\n\nDoes anybody have code to stage commits using a the visual diff/merge \ntools supported by git-difftool?  Is there support in git itself \nsomewhere, even?\n\nI'm looking for something functionally similar to git add -p\n\nLooking at the git-difftool source I can see how to write a command to do \nit, but wanted to check if it had already been implemented.\n\nDid I miss a way that already exists?\n\nThanks\n\n\nJohn\n"},{"id":"262216","messageId":"20150527072826.GC6898@peff.net","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1505262147230.3709@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-27T07:28:26Z","receivedAt":"2015-05-27T07:28:26Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:\n\n> Does anybody have code to stage commits using a the visual diff/merge tools\n> supported by git-difftool?  Is there support in git itself somewhere, even?\n> \n> I'm looking for something functionally similar to git add -p\n> \n> Looking at the git-difftool source I can see how to write a command to do\n> it, but wanted to check if it had already been implemented.\n> \n> Did I miss a way that already exists?\n\ngit-gui has a visual staging tool, and I think some other git interfaces\ndo, too (e.g., tig). But I don't think there is a way to interact with\nan arbitrary 3rd-party diff tool. I would think doing so would depend on\nthe diff tool itself; what facility does it provide for picking lines\nor a hunk out of a diff and communicating it back to git to stage?\n\nIf you are interested in looking further, see how the %patch_mode hash\nis defined in git-add--interactive.perl. Specifically, note that \"add\n-p\" is just one case: diff against the index and apply with \"apply\n--cached\". But once you have a separate tool for picking hunks, you\nshould be able to drop in the different DIFF/APPLY pairs to implement\n\"checkout -p\", etc.\n\n-Peff\n"},{"id":"262217","messageId":"alpine.DEB.2.10.1505270831490.4687@alice","threadId":"39428","inReplyTo":"20150527072826.GC6898@peff.net","subject":"Re: Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-05-27T07:34:43Z","receivedAt":"2015-05-27T07:34:43Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"On Wed, 27 May 2015, Jeff King wrote:\n\n> If you are interested in looking further, see how the %patch_mode hash\n> is defined in git-add--interactive.perl. Specifically, note that \"add\n> -p\" is just one case: diff against the index and apply with \"apply\n> --cached\". But once you have a separate tool for picking hunks, you\n> should be able to drop in the different DIFF/APPLY pairs to implement\n> \"checkout -p\", etc.\n\nMy plan was to use symlinks, checkout-index, and update-index \n--index-info, similar to how difftool does it.  I verified on the command \nline that that seems to work.\n\n\nJohn\n"},{"id":"262400","messageId":"55683818.5010002@drmicha.warpmail.net","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1505270831490.4687@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-05-29T09:57:44Z","receivedAt":"2015-05-29T09:57:44Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"John Lee venit, vidit, dixit 27.05.2015 09:34:\n> On Wed, 27 May 2015, Jeff King wrote:\n> \n>> If you are interested in looking further, see how the %patch_mode hash\n>> is defined in git-add--interactive.perl. Specifically, note that \"add\n>> -p\" is just one case: diff against the index and apply with \"apply\n>> --cached\". But once you have a separate tool for picking hunks, you\n>> should be able to drop in the different DIFF/APPLY pairs to implement\n>> \"checkout -p\", etc.\n> \n> My plan was to use symlinks, checkout-index, and update-index \n> --index-info, similar to how difftool does it.  I verified on the command \n> line that that seems to work.\n> \n> \n> John\n> \n\nYes, having \"git addtool\" (or \"stagetool\") to go with difftool and merge\ntool would be nice, and it could hopefully resuse code or infrastructure\nfrom those tools, as well as the tool config.\n\nI vaguely remember a sketch or proof-of-concept by Jeff (not reusing\n*tool) but may be wrong.\n\nMichael\n"},{"id":"262490","messageId":"20150531015956.GA64502@gmail.com","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1505262147230.3709@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-05-31T01:59:57Z","receivedAt":"2015-05-31T01:59:57Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:\n> Hi\n> \n> Does anybody have code to stage commits using a the visual\n> diff/merge tools supported by git-difftool?  Is there support in git\n> itself somewhere, even?\n> \n> I'm looking for something functionally similar to git add -p\n> \n> Looking at the git-difftool source I can see how to write a command\n> to do it, but wanted to check if it had already been implemented.\n> \n> Did I miss a way that already exists?\n> \n> Thanks\n> \n> \n> John\n\nIf you're interested in existing staging tools then I would\nhighly suggest looking at git-cola.\n\n    https://github.com/git-cola/git-cola\n\n    git clone git://github.com/git-cola/git-cola.git\n\ngit-cola is free software so it's pretty unique in many ways.\nI also wrote it, so that makes it that much more awesome ;-)\n\ncola has a very slick interactive staging editor, interactive\nrebase, and a whole lot more.\n\nI'm a g/vim user, so git-cola is finely tuned for keyboard\nusage.  If we implement these feature in Git, we should consider\nproviding the same workflows/hotkeys as cola.\n\nFor staging, you can select lines, hit \"s\", and they'll be\nstaged/unstaged.  ctrl-u reverts unstaged edits, etc.\nThe '?' hotkey shows the help, etc.\n\nYou can get extremely granular, moreso then \"add -p\", which is\nwhy it exists.  When cola's diff editor is not sufficient, you\ncan also use it to drive difftool, but only in ways that you can\non the command-line already.\n\ngit-cola is written in Python(2+3) so it's easy to hack on, and\nquite portable.\n\ncheers,\n-- \nDavid\n"},{"id":"262511","messageId":"alpine.DEB.2.10.1505311029210.3664@alice","threadId":"39428","inReplyTo":"20150531015956.GA64502@gmail.com","subject":"Re: Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-05-31T09:36:52Z","receivedAt":"2015-05-31T09:36:52Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"On Sat, 30 May 2015, David Aguilar wrote:\n\n> On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:\n>> Hi\n>>\n>> Does anybody have code to stage commits using a the visual\n>> diff/merge tools supported by git-difftool?  Is there support in git\n...\n> I'm a g/vim user, so git-cola is finely tuned for keyboard\n> usage.  If we implement these feature in Git, we should consider\n> providing the same workflows/hotkeys as cola.\n\nJust to be clear I'm not planning on contributing my script back to git, \nit will just be a standalone script in a separate repo.\n\nI'll give git-cola a try, thanks.  I just ran it and see it supports e.g. \nright click to stage and launching difftools -- does it also support \nlaunching a difftool to edit the index?\n\n\nJohn\n"},{"id":"262554","messageId":"20150601022515.GA66417@gmail.com","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1505311029210.3664@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-06-01T02:25:17Z","receivedAt":"2015-06-01T02:25:17Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, May 31, 2015 at 10:36:52AM +0100, John Lee wrote:\n> On Sat, 30 May 2015, David Aguilar wrote:\n> \n> >On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:\n> >>Hi\n> >>\n> >>Does anybody have code to stage commits using a the visual\n> >>diff/merge tools supported by git-difftool?  Is there support in git\n> ...\n> >I'm a g/vim user, so git-cola is finely tuned for keyboard\n> >usage.  If we implement these feature in Git, we should consider\n> >providing the same workflows/hotkeys as cola.\n> \n> Just to be clear I'm not planning on contributing my script back to\n> git, it will just be a standalone script in a separate repo.\n> \n> I'll give git-cola a try, thanks.  I just ran it and see it supports\n> e.g. right click to stage and launching difftools -- does it also\n> support launching a difftool to edit the index?\n\nIf you have stuff staged and use ctrl-d (or right-click->difftool),\ngit cola will run, \"git difftool --staged -- <path>\".\n\ndifftool will already point back to your worktree whenever\npossible through the GIT_EXTERNAL_DIFF machinery that it uses.\n\nAfter changes are made in the worktree you select files, lines,\nor hunks and stage them.  Doing it in one step could be as\nsimple as having a script to automatically call \"git add\" after\ndifftool, or \"ctrl-s\" in cola to stage the whole file.\n\nA not as simple (but potentially quite helpful) use case is a\ntool that does a 3-way merge between HEAD, index, and worktree,\nand writes the result back to the worktree (or index?).\nThe mergetool--lib backend could be leveraged for that feature.\n\nWere you thinking of something like this, or something else?\nCan you describe your use case a bit more?\n\nIt seems like we have most of the use cases covered with stock\ngit, but I'm not sure if I'm missing something.\n\ncheers,\n-- \nDavid\n"},{"id":"262647","messageId":"alpine.DEB.2.10.1506012034120.2730@alice","threadId":"39428","inReplyTo":"20150601022515.GA66417@gmail.com","subject":"Re: Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-06-01T19:36:14Z","receivedAt":"2015-06-01T19:36:14Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"On Sun, 31 May 2015, David Aguilar wrote:\n> Were you thinking of something like this, or something else?\n> Can you describe your use case a bit more?\n\nI think now I should just publish my script and then it will be very clear \nwhat I'm talking about.  If somebody then wants to add a similar feature \nto git-cola, or even git itself, that would be great.\n\n\nJohn\n"},{"id":"265035","messageId":"alpine.DEB.2.10.1506272359240.31567@alice","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1506012034120.2730@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-06-27T23:23:53Z","receivedAt":"2015-06-27T23:23:53Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"On Mon, 1 Jun 2015, John Lee wrote:\n\n> On Sun, 31 May 2015, David Aguilar wrote:\n>> Were you thinking of something like this, or something else?\n>> Can you describe your use case a bit more?\n>\n> I think now I should just publish my script and then it will be very clear \n> what I'm talking about.  If somebody then wants to add a similar feature to \n> git-cola, or even git itself, that would be great.\n>\n>\n> John\n>\n\nHere it is:\n\nhttps://github.com/jjlee/git-meld-index\n\nHasn't seen use for real yet, so be a bit cautious with it.\n\nComments / patches / whatever appreciated.\n\n\nJohn\n"},{"id":"265093","messageId":"alpine.DEB.2.10.1506281852230.31567@alice","threadId":"39428","inReplyTo":"alpine.DEB.2.10.1506272359240.31567@alice","subject":"Re: Staging commits with visual diff tools?","fromName":"John Lee","fromEmail":"jjl@pobox.com","sentAt":"2015-06-28T17:56:58Z","receivedAt":"2015-06-28T17:56:58Z","isPatch":false,"sender":{"key":"jjl@pobox.com","avatar":null},"body":"On Sun, 28 Jun 2015, John Lee wrote:\n\n> Here it is:\n>\n> https://github.com/jjlee/git-meld-index\n>\n> Hasn't seen use for real yet, so be a bit cautious with it.\n>\n> Comments / patches / whatever appreciated.\n>\n>\n> John\n>\n\nBy the way despite the name it should support all git difftools (it uses \nthe same git config parameters and git-mergetool--lib code as git itself).\n\nI just used it to make some changes to its own project, quite nice :-)\n\nIt now has a --help manpage and some relevant options from git-difftool.\n\n\nJohn\n"}]}