19

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?

Community
  • 1
  • 1
JXG
  • 7,263
  • 7
  • 32
  • 63
  • 2
    I would have upvoted this, but apparently I did so when running into the same issue 2 months ago. – Kendall Frey Jun 13 '13 at 18:29
  • 3
    Cleartool has a [diff](http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m1/index.jsp?topic=/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_diff.htm) command. Check the -diff_format option for a standard Unix style output. – John Aug 26 '13 at 18:20
  • I keep re-googling this question, and keep ending up using [WinMerge](http://winmerge.org/) to make a patch file (since you mention Windows, I thought adding WinMerge as a comment was fair game). His post's a little old, but [Joachim said it doesn't exist in KDiff3 back in Dec 2011](http://sourceforge.net/p/kdiff3/discussion/197500/thread/59c87108/), and I took that somewhat quick answer to mean that it's not likely to come later. YMMV. – ruffin Feb 12 '15 at 20:09

2 Answers2

8

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).

Felix
  • 433
  • 4
  • 8
-4

Don't bother with kdiff3. The command you're looking for is

cleartool diff --diff-format

Answered by John here: From a kdiff3 file comparison, can I generate a diff in unified diff format?

Community
  • 1
  • 1
Quuxplusone
  • 23,928
  • 8
  • 94
  • 159