A visual patch tool for Linux

Viewed 26037

I've got a file and a patch for it. I'd like to visually apply the patch, t.i. see how the changes proposed by the patch look in context, make some corrections, and save the resulting file.

What tool can do that?

Neither of the visual diff tools (i.e. meld, diffuse, diffmerge) do what I want: they don't work with patches, they merely merge whole files.

9 Answers

I really like Kompare. It is just a (very nice) graphical interface for diff.

http://www.caffeinated.me.uk/kompare/

sudo apt-get install kompare

Creating and applying patches

Kompare is able to create a patch file which lists only the differences between two compared text files A and B. Further, Kompare can apply a patch file which was created this way to an original file A and, in this manner, recompute the contents of the corresponding file B. This is a comfortable utility for passing a corrected version of a file to a friend who already has an older version of the same file, because only the (relatively small) patch file has to be delivered and the receiver can generate the corrected file by applying the patch to the original file.

The patches created and applied by Kompare are compatible to patch files generated or applied by the command line interface diff utility, because Kompare is in fact merely a graphical front end to diff and the patches are created and applied by patch, which gets called by Kompare.

See use vimdiff with a diff file.

gvim original.file +'vert diffpa the.patch'

This will open GVim and split the window, with the original on the left and the patch applied on the right. You can then add, remove, or change hunks, and save the changes. (Well, if you want to create a new.patch you'll have to run diff again, but that's not difficult.)

Another option: if you use Eclipse, you can generate and apply patches visually.

I normally use GitExtensions (.NET and Mono) which also supports applying patches interactively. I hope you are already familiar with git.

Edit: Everything mentioned below this line doesn't seem to be available directly in KDiff3. And as I mentioned before: I haven't tried it yet.

GitExtension normally uses KDiff3 as diff tool, which is able to view patches.

http://kdiff3.sourceforge.net/doc/kpart.html

Using it for patches it has only a two window view, (edit) and doesn't support merging :( but it also supports 3 way diff on complete folders etc.

Actually I never tryed it with patches.

I'd use meld.

Create two copies of the files, one without and another with the patch. Use meld to compare them, and you can see exactly what the patch is changing and make changes as necessary.

Seriously, why is this so hard?

Related