Can't configure SourceTree on Windows to run KDiff3

I have KDiff3 installed under c:/Program Files (x86)/KDiff3, but when I select KDiff3 for the External Diff tool and I diff a file using the right button External Diff menu item, nothing happens. I also tried selecting the Custom option for the External Diff Tool and entering the full path to the exe in the Diff Command entry box and again nothing happened when selecting the External Diff menu.

Windows 7

Thanks for any help.

Glen

12 answers

1 accepted

0 votes
Accepted answer

So your recent comment made me realize that SourceTree wasn't using the correct home directory, so it wasn't modifying the correct .gitconfig nor was it using it. My system is running in an Enterprise environemnt and they have the HOMEDRIVE set to an invalid drive on my system. What was confusing was when SourceTree started a terminal, it figured out the correct home directory.

So I created an appropriate mapping for the HOMEDRIVE as described at http://superuser.com/questions/255776/overriding-homedrive-and-homepath-as-a-windows-7-user/483900#483900 and it now works.

Thanks for the help.

Hmm, what version of SourceTree are you using? The latest is 1.0.7, and I have KDiff3 in exactly the same location in Win7x64 and selecting KDiff3 from the options works fine for me in both git and hg.

If you are using 1.0.7, please can you give more information of what you're trying to diff, maybe there's something specific about that.

I was using 1.0.6 and this was happending, so I upgraded to 1.0.7 and nothing changed.

I'm just trying to diff *.java and *.cs files.

I tried un-installing SourceTree, deleting the C:\Users\<user name>\AppData\Local\Atlassian directory, and then re-installing. Still nothing happens when I try to do an external diff.

Glen

I was using 1.0.6 and this was happending, so I upgraded to 1.0.7 and nothing changed.

I'm just trying to diff *.java and *.cs files.

I tried un-installing SourceTree, deleting the C:\Users\<user name>\AppData\Local\Atlassian directory, and then re-installing. Still nothing happens when I try to do an external diff.

Glen

Are those files in locations which have anything unusual about them, such as extended code page characters?

The files are located 3 directory levels down from C: with only upper and lower case letters and the - character.

I also tried running KDiff from the SourceTree terminal using full windows style paths for the executable and files, all surronded by quotes ("), and it worked fine.

Just updated to 1.0.8 and still have the same problem, both selecting the KDiff3 option or the custom option.

Also tried using the custom diff option and running the following bat script. The bat script was never run.

echo "starting with %1 %2" >c:\users\myid\diffTest.log
"C:\Program Files (x86)\KDiff3\kdiff3" %1 %2

It's not actually a valid test to use this .bat file - that works if you call the .bat from a standard command line but not when it's invoked from Git, which actually uses a Bash shell and neither the redirection nor the argument expansion works. If you wanted to use a .bat file like this with you'd actually have to call 'cmd.exe' to interpret it.

The thing you have to bear in mind is that when used as an external diff it's git that's calling the diff tool and not SourceTree or a regular Windows command prompt. If you want to do a throrough test which eliminates SourceTree you have to edit your %USER%\.gitconfig file and edit the diff tool section:

[difftool "sourcetree"]
	cmd = 'C:/Program Files (x86)/KDiff3/kdiff3.exe' \"$LOCAL\" \"$REMOTE\"

SourceTree automatically changes the \ to / for you (git only likes '/') and quotes the path for you. Testing this on the command line can be done with

git difftool --tool=sourcetree filename.txt

I've tested this here with a brand new install of KDiff3 in the standard location, and my difftool configuration is exactly like the above, and works perfectly. The only thing I can think of is that it's something to do with the characters in the path, please can you be more specific about the exact path of the files.

So I uninstalled and reinstalled both SourceTree (now 1.0.8) and Kdiff3 (64bit version). I've changed my .gitconfig to:

[diff]
        tool = kdiff3
[merge]
        tool = kdiff3
[difftool "kdiff3"]
        cmd = 'c:/Program Files/KDiff3/kdiff3.exe' \"$LOCAL\" \"$REMOTE\"
[difftool "sourcetree"]
        cmd = 'c:/Program Files/KDiff3/kdiff3.exe' \"$LOCAL\" \"$REMOTE\"

Now I can use the following commands in the SourceTree terminal successfully.

git difftool publish.bat
git difftool --tool=kdiff3 publish.bat
git difftool --tool=sourcetree publish.bat

So I then tried the External Diff command in SourceTree with the External Diff Tool setting to either "System Default" or "KDiff3" and neither work. I've tried external diff'ing the following 2 files and neither work: /c/aWork/dc-win/publish.bat and /s/gui/SSD/MMM/GGG/main.xml

So let me confirm so that we're absolutely clear - when you manually configure KDiff3 in your .gitconfig, external diff works in SourceTree too, with the same set of files that you've been using all along, by configuring your .gitconfig like this:

[difftool "sourcetree"]
        cmd = 'c:/Program Files/KDiff3/kdiff3.exe' \"$LOCAL\" \"$REMOTE\"

Yet if you configure KDiff3 inside SourceTree, it stops working?

When you configure KDiff3 in SourceTree, it's simply writing this same configuration section in your .gitconfig (the difftool "sourcetree" section only). It *should* configure it exactly like the above, assuming it finds KDiff3 in that location. Can you show me what your .gitconfig looks like after you use SourceTree's Preferences to configure KDiff3?

I solved this by installing KDiff3 into a directory which hasn't a space inside the installation path c:\KDiff3 instead of C:\Program Files\KDiff3. After that it works fine.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

702 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you