Miscellaneous Topics

Networktransparency via KIO

KIO-Slaves
The KIO library from Frameworks supports networktransparency via KIO-slaves. KDiff3 uses this for reading input files and for scanning directories. This means that you can specify files and directories on local and remote resources via URLs.
Example:

   kdiff3 test.cpp  ftp://ftp.faraway.org/test.cpp
   kdiff3 tar:/home/hacker/archive.tar.gz/dir ./dir

The first line compares a local file with a file on an FTP-server. The second line compares a directory within an compressed archive with a local directory.
Other KIO-slaves that are interesting are:
Files from the WWW (http:),
Files from the FTP (ftp:),
Encrypted file transfer (fish:, sftp:),
Windows-resources (smb:),
Local files (file:),
Other things that are possible, but probably less useful are:
Man-pages (man:),
Info-pages (info:),

How To Write URLs
An URL has a different syntax compared with paths for local files and directories. Some things should be considered:
A path can be relative and can contain "." or "..". This is not possible for URLs which are always absolute.
Special characters must be written with "escaping". ("#"->"%23", space->"%20", etc.) E.g. A file with the name "/#foo#" would have the URL "file:/%23foo%23".
When URLs don't work as expected, try to open them in Konqueror first.

Capabilities of KIO-Slaves
Networktransparency has one drawback: Not all resources have the same capabilities.
Sometimes this is due to the file system of the server, sometimes due to the protocol. Here is a short list of restrictions:
Sometimes there is no support for links.
Or there is no way to distinguish if a link points to a file or a directory; always assuming a file. (ftp:, sftp:).
Can't always determine the filesize.
Limited support for permissions.
No possibility to modify permissions or modification time, so permissions or time of a copy will differ from the original. (See the option "Trust the size".) (To modify permissions or modification time is only possible for local files.)

Using KDiff3 as a KPart
KDiff3 is a KPart. Currently it implements the KParts::ReadOnlyPart-interface.
It's main use is as difference-viewer in KDevelop. KDevelop always starts the internal difference viewer first. To invoke KDiff3 press the right mouse button on the difference viewer window and select "Show in KDiff3Part" from the context menu.
KDiff3 normally requires two complete files as input. When used as part KDiff3 will assume that the input file is a patch-file in the unified format. KDiff3 then retrieves the original filenames from the patch-file. At least one of the two files must be available. KDiff3 will then invoke patch to recreate the second file.
In you can select a patch-file and select "Preview in"-"KDiff3Part" from the context menu. Be aware that this won't work if none of the original files are available, and it is not reliable if the original file(s) have changed since the patch-file was generated.
When run as a part KDiff3 only provides the a two-file-diff, a very small toolbar and menu. Merging or directory-comparison are not supported then.

Using KDiff3 as a Git Diff and Merging Tool
KDiff3 can be used as a Git diff and merge tool.
Just add the following lines into your gitconfig file.

[diff]
        tool = kdiff3
[difftool "kdiff3"]
        path = <path to kdiff3 binary in your system>
[difftool]
        prompt = false
        keepBackup = false
        trustExitCode = false
[merge]
        tool = kdiff3
[mergetool]
        prompt = false
        keepBackup = false
        keepTemporaries = false
[mergetool "kdiff3"]
        path = <path to kdiff3 binary in your system>

Then to see the difference between two commits use git difftool first_hash second_hash --tool=kdiff3 --cc some_file_in_the_git_tree
To merge a branch with KDiff3 use git merge branch_name && git mergetool --tool=kdiff3
After resolving merging conflicts in the usual way it is enough to commit the changes to do the job.