Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can't configure SourceTree on Windows to run KDiff3

Glen Purdy July 25, 2013

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
Answer accepted
Glen Purdy July 30, 2013

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.

0 votes
Heymen Nicolaij November 30, 2015

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.

RadekJakubik2 July 25, 2019

Exactly!! The same problem, the same solution. Thanks.

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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?

0 votes
Glen Purdy July 30, 2013

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

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

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.

0 votes
Glen Purdy July 29, 2013

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

0 votes
Glen Purdy July 29, 2013

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

0 votes
Glen Purdy July 29, 2013

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.

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2013

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

0 votes
Glen Purdy July 25, 2013

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

0 votes
Glen Purdy July 25, 2013

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

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events