{"thread":{"id":"26068","subject":"Can `add --patch` display the diff in my difftool instead of just printing it on the command line?","startedAt":"2010-12-14T21:17:09Z","lastAt":"2010-12-14T22:22:27Z","messageCount":3,"participants":["Dun Peal","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158093","messageId":"AANLkTi=_VyUAL+qjWLEcThX-zC5n0v0WB-W7hTSZn0ae@mail.gmail.com","threadId":"26068","inReplyTo":null,"subject":"Can `add --patch` display the diff in my difftool instead of just printing it on the command line?","fromName":"Dun Peal","fromEmail":"dunpealer@gmail.com","sentAt":"2010-12-14T21:17:09Z","receivedAt":"2010-12-14T21:17:09Z","isPatch":false,"sender":{"key":"dunpealer@gmail.com","avatar":"https://gravatar.com/avatar/42f3e6a1166eb44e33f24c20ccbe809fa8591413f366dfe3755c8a8d4935ace9?d=mp&s=160"},"body":"Hi.\n\nI'd like to display the diff of each modified working copy file, and\nhave the option of staging (or reversing) each patch after it is\ndisplayed. This is exactly the same thing `add --patch` does, except I\nwant the diff to be displayed in my difftool (happens to be vimdiff)\nrather than just being printed.\n\nThanks, D.\n"},{"id":"158094","messageId":"20101214213810.GB2216@sigill.intra.peff.net","threadId":"26068","inReplyTo":"AANLkTi=_VyUAL+qjWLEcThX-zC5n0v0WB-W7hTSZn0ae@mail.gmail.com","subject":"Re: Can `add --patch` display the diff in my difftool instead of just printing it on the command line?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-12-14T21:38:10Z","receivedAt":"2010-12-14T21:38:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 14, 2010 at 03:17:09PM -0600, Dun Peal wrote:\n\n> I'd like to display the diff of each modified working copy file, and\n> have the option of staging (or reversing) each patch after it is\n> displayed. This is exactly the same thing `add --patch` does, except I\n> want the diff to be displayed in my difftool (happens to be vimdiff)\n> rather than just being printed.\n\nYou can't do this with \"git add -p\" now, but I suspect the patch would\nbe relatively straightforward. See patch_update_file in\ngit-add--interactive.perl. You just need to replace:\n\n  for (@{$head->{DISPLAY}}) {\n    print;\n  }\n\nwith code to dump the diff in @{$head->{TEXT}} either to stdin of your\ndisplay program or to a tempfile that your program operates on.\nConditional on having some config option to specify your program, of\ncourse.\n\nOr did you want something more integrated with vimdiff? If you want to\nprimarily see the diff in vim and then have mappings set up to stage or\nrevert changes, that is pretty straightforward to do. Just have vim dump\nthe relevant hunk to \"git apply --cached\" or \"git apply -R\". I would be\nsurprised if the vim integration packages didn't have something like\nthis already.\n\n-Peff\n"},{"id":"158100","messageId":"AANLkTimV3eQuLcUcoTHWOeXCNoGoboSggkVfoxvVcx8X@mail.gmail.com","threadId":"26068","inReplyTo":"20101214213810.GB2216@sigill.intra.peff.net","subject":"Re: Can `add --patch` display the diff in my difftool instead of just printing it on the command line?","fromName":"Dun Peal","fromEmail":"dunpealer@gmail.com","sentAt":"2010-12-14T22:22:27Z","receivedAt":"2010-12-14T22:22:27Z","isPatch":false,"sender":{"key":"dunpealer@gmail.com","avatar":"https://gravatar.com/avatar/42f3e6a1166eb44e33f24c20ccbe809fa8591413f366dfe3755c8a8d4935ace9?d=mp&s=160"},"body":"On Tue, Dec 14, 2010 at 3:38 PM, Jeff King <peff@peff.net> wrote:\n> You can't do this with \"git add -p\" now, but I suspect the patch would\n> be relatively straightforward. See patch_update_file in\n> git-add--interactive.perl. You just need to replace:\n>\n>  for (@{$head->{DISPLAY}}) {\n>    print;\n>  }\n>\n> with code to dump the diff in @{$head->{TEXT}} either to stdin of your\n> display program or to a tempfile that your program operates on.\n> Conditional on having some config option to specify your program, of\n> course.\n\nThat's exactly what I want, thanks. Seems like there should be a flag\n/ config that tells `add --interactive` to render the diffs through a\ndifftool. I know several Git users who always use their difftools for\nlarge, complex patches, which are exactly the kind of patches you'd\nmanage with --interactive / --patch. Hope one of you Git bigwigs takes\nthe time to add that feature :-)\n\n.D\n"}]}