Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From a kdiff3 file comparison, can I generate a diff in unified diff format?

I have a kdiff3 comparison in Windows, and I would like to save the comparison as a text file in unified diff format.

I realize this is kind of a strange question. Usually, people already have the text diff in hand, and want to see it graphically in kdiff3.

I'm using an ... unusual ... version control tool in Windows, and it can compare versions and display the comparison in kdiff3. However, it is decidedly unfriendly in generating Unix-friendly output, at least for non-ClearCase-ninjas like me.

What I would really, truly, love is to get the output of the comparison in a unified diff format, so I can use tools like patch or similar. I do not particularly love ClearCase, and I would be happy to leave it alone as much as possible.

Can kdiff3 take an existing comparison and export it to a unified diff format?

like image 336
JXG Avatar asked Oct 10 '12 18:10

JXG


People also ask

How does KDiff3 work?

KDiff3 can be used to merge two or three input files and automatically merges as much as possible. The result is presented in an editable window where most conflicts can be solved with a single mouseclick: Select the buttons A/B/C from the button-bar to select the source that should be used.

How do you save KDiff3?

So if you "kill" a KDiff3 instance then your data will be lost.) Line endings are saved according to the normal method on the underlying operating system. For Unices each line ends with an linefeed-character " \n ", while for Win32-based systems each line ends with a carriage-return + a linefeed " \r\n ".


1 Answers

kdiff3 in Windows tends to come with the standard command-line diff utils as well -- look in your C:\Program Files*\KDiff3\bin folder; if diff.exe is there, you can use that (the standard diff -u file1 file2). (If it's not there, re-run the kdiff3 installer and select the "Utilities" option.)

If you're looking at some files in a running kdiff3 that was auto-launched from ClearCase, open a command prompt in the kdiff3 bin directory (or copy the contents of the bin directory into C:\Windows to make these commands work from anywhere) and do:

diff -u "<copy-pasted path of file A>" "<copy-pasted path of file B>"

where the paths for file A and file B come from your kdiff3 window (doesn't matter if they're temporary files; they'll exist as long as the kdiff3 window is open).

like image 85
Felix Avatar answered Sep 28 '22 06:09

Felix