When two or more people are working on a file and passing it back and forth between one another, it becomes difficult to see what changes have been made to a new version or copy of the file. Opening the new copy and the original, side-by-side in the application used to create it is one solution but, laborious, time consuming, and prone to error. This is where a program to show differences, diffs for short, is useful.
As would be expected, an appropriate name for such a program would be "diff". As it happens, the program diff is installed on most Linux®-based systems and is used for exactly this purpose. Developers often use diff, as a command line tool, to show differences between versions of a source code file. However, the use of diff is not limited to showing differences in code source files, it can be used on many text-based file types.
Using diff from the command line can be confusing, learning the diff command syntax and deciphering the output can bewilder most people. This is where Kompare comes into play. Providing a graphical front-end to the diff program, the interface displays source and destination files side-by-side with all differences automatically highlighted. From this starting point, changes in one file can be sequentially applied to the other file on a selective and controlled basis. Not all changes need to be applied and if you do apply a change it can always be 'unapplied'. When all required changes have been applied they can be saved and will display as normal in the original application used to create the file.
In addition to displaying differences between a source and destination file, Kompare can be used to create and view a special file called a 'diff'. This file captures the differences between the two sources into a single file that can be used to view and apply changes to any other copy of the file. For example, if two people are editing a document. The first person wants to make changes and send just the changes made to the second person. Normally, the first person would send a complete copy of the modified document to the second person, who would then have to compare the modified document side-by-side with unmodified version. The process for this is much like what we have described in the previous paragraphs. With Kompare the first person would first make a local copy of the file to be modified, then make changes and compare the original and modified copy. Now using Kompare a diff file can be created that captures only the changes made. This can be sent to the second person in place of a whole file containing the changes.
Using Kompare the second person can view the diff file, compare it to the local copy of the document and apply the changes made by the first person. So the process can go on for many versions of the document, each person making changes, creating diffs, distributing them and applying them. This process is commonly called "patching", a term taken from the program named "patch" which is another command line tool specifically designed for the purpose of applying diff files.
It sometimes happens that people edit a file at the same time. In this situation it is likely that people will make changes in the document at exactly the same line. This creates a problem because, without applied caution, people could be overwriting each others work as they apply the diff files they receive. Fortunately the developers of the diff and patch programs took this into consideration and so these tools will not allow such changes to be applied without manual intervention. When this state is reached, it is known as a "conflict". Kompare will display conflicts so that you can manually resolve them, deciding which changes should be applied to which file.
Kompare is also a great program for comparison of file changes on a folder level. When used to compare folders Kompare recursively examines subfolders and their file contents for differences. In this use case, each file where differences are found are automatically opened and listed by Kompare where easy navigation between the various files is possible.