Often when I do diffs I want to edit my local file before committing. This works very well in Eclipse's compare view as it allows you to easily edit the local file as well as copy changes from the previous version.
I am trying to set up Git and KDiff3 to work the same way. It works as expected when I'm using KDiff3 as my mergetool. However when I set it up as the difftool, it gives me a read-only view, so I can't do any edits. According to the documentation (http://kdiff3.sourceforge.net/doc/documentation.html), I would expect the --output
option to give me the two file merge I want, but it does not. The relevant part of my .gitconfig:
[diff]
tool = kdiff3
[difftool "kdiff3"]
cmd = /Applications/kdiff3.app/Contents/MacOS/kdiff3 $LOCAL $REMOTE --output $LOCAL
trustExitCode = false
I can use KDiff3 to edit the in-tree file if I use the following command:
kdiff3 $LOCAL $REMOTE --output $MERGED
KDiff3 is in my $PATH
, so the important bit is to change the output from $LOCAL
to instead be $MERGED
.
From the git-difftool
manpage:
...the configured command line will be invoked with the following variables available: $LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and $REMOTE is set to the name of the temporary file containing the contents of the diff post-image. $MERGED is the name of the file which is being compared.
Since setting the output to $LOCAL
is going to write to a temporary file, you'll instead want to write to $MERGED
since that will be the actual "local" in-tree file.