Working with Diff Files

Diff files contain only the changes made between files, or a set of files within a folder system, and may or may not contain a number of context lines before and after line changes. The sum of a line change and its context lines is known a hunk. A diff file therefore may contain multiple hunks from one or more files. When the context lines of two or more hunks overlap, they are considered a single hunk. Diff files can be used to:

  • Apply the changes contained in the hunks to an original file.

  • Apply the changes contained in the hunks to a file or set of original files within a folder system.

  • Modified before being applied to an original file or set of original files within a folder system.

Creating a Diff

To create a diff file a comparison must be displayed in Kompare. Assuming this is the case, then select FileSave Diff... This will display the Diff Options dialog (see the section called “Diff Settings” for more information on diff formats and options). After configuring these options, click the Save button and save the diff to a file with the extension .diff.

Displaying a Diff

It is possible to display the contents of a diff file within Kompare by opening the diff file from FileOpen Diff....

When viewing a diff file the hunks between the source and destination file are shown, remember that only the hunks are shown, no unmodified lines will be shown. In some cases a diff file is created with 0 lines of context. In this case only the changed lines will be displayed.

When a diff file contains hunks from multiple files Kompare displays the hunks from each file one at a time and you can switch between files as though they were real files even though this information is only provided by the diff file contents.

Applying Differences in a Diff File

When viewing differences in a diff file it is possible to apply difference as you would when comparing source and destination files (see the section called “Merging Differences”).

Blending a URL with a Diff

In cases where a diff file is provided it is possible to compare the hunks in the diff against a file or folder. To do this select FileBlend URL with Diff.... Then input the File/Folder and Diff Output paths.

When viewing differences between a source file and a diff file it is possible to apply difference as you would when comparing source and destination files (see the section called “Merging Differences”).