Re: Can `add --patch` display the diff in my difftool instead of just printing it on the command line?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 14, 2010 at 03:17:09PM -0600, Dun Peal wrote:

> I'd like to display the diff of each modified working copy file, and
> have the option of staging (or reversing) each patch after it is
> displayed. This is exactly the same thing `add --patch` does, except I
> want the diff to be displayed in my difftool (happens to be vimdiff)
> rather than just being printed.

You can't do this with "git add -p" now, but I suspect the patch would
be relatively straightforward. See patch_update_file in
git-add--interactive.perl. You just need to replace:

  for (@{$head->{DISPLAY}}) {
    print;
  }

with code to dump the diff in @{$head->{TEXT}} either to stdin of your
display program or to a tempfile that your program operates on.
Conditional on having some config option to specify your program, of
course.

Or did you want something more integrated with vimdiff? If you want to
primarily see the diff in vim and then have mappings set up to stage or
revert changes, that is pretty straightforward to do. Just have vim dump
the relevant hunk to "git apply --cached" or "git apply -R". I would be
surprised if the vim integration packages didn't have something like
this already.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]