KDiff3 under cygwin git will not invoke
Asked Answered
S

3

3

In keeping with a number of solutions posted on the internet I have installed KDiff3 and modified .gitconfig as below to make use of it. Nonetheless, when I run git diff HEAD^ HEAD within a repository to test it I get a diff performed by the default tool. I'm running cygwin git on Windows7-64. Can anyone explain why KDiff3 is not invoked?

[diff]
    tool = kdiff3
[merge]
    tool = kdiff3

[difftool "kdiff3"]
    path = \"D:/Program Files (x86)/KDiff3/kdiff3.exe\"
    keepBackup = false
    trustExitCode = false

[mergetool "kdiff3"]
    path = \"D:/Program Files (x86)/KDiff3/kdiff3.exe\"
    keepBackup = false
    trustExitCode = false
Stipitate answered 26/2, 2013 at 18:53 Comment(2)
Where are the various pieces running? Is this all (I hope!) in Cygwin? Are parts native windows applications and if so, which?Giraldo
Yes, its running in cygwin, see jturney's response for where I've got to.Stipitate
P
2

Use git difftool to invoke the configured diff tool, not git diff.

Since you seem to be using cygwin git, but a native kdiff3, you'll probably also need to invoke a wrapper script, rather than kdiff3 directly, to use cygpath convert paths from cygwin form to native form.

Pledget answered 26/2, 2013 at 20:15 Comment(7)
... and Google quickly finds an example of such a scriptPledget
Doing so results in: Viewing: 'file.py' Launch 'kdiff3' [Y/n]: Y After which the tool doesn't launch, I take it the wrapper will resolve this?Stipitate
Using the windows form of the path to kdiff3 seems unlikely to work. Have you tried using the wrapper script?Pledget
OK, I've tried this with the wrapper script. I still get the Launch 'kdiff3' prompt. I respond with Y. Once I do so the response is: "The diff tool kdiff3 is not available as '~/bin/kdiff3.sh'". Note that calling ~/bin/kdiff3.sh successfully starts Kdiff when called on the command line.Stipitate
Hmm.. it seems that page isn't quite right, you can't put ~ in a .gitconfig file, so replace that with /home/jon or whatever your $HOME directory is.Pledget
I made two significant changes to the linked kdiff3.sh script. First to handle embedded spaces in file name: OUT="'!cygpath -wa \"$arg\"!'" (backticks written as ! here...). And secondly avoid making kdiff3 complain when looking at an added/removed file: if [[ "$arg" = "/dev/null" ]]; then arg="/cygdrive/c/some_zero_byte_file"; fi right in front of the OUT=... line.Mast
Adding home directory instead of ~ did not work for me. Am I missing something ? [mergetool "kdiff3"] path = /home/stadikon/kdiff3.sh keepBackup = false trustExitCode = falseBogeyman
P
3

Actually, the wrapper script is not needed. If kdiff3.exe is not in your path, you need to give the full path in cmd as cmd = /cygdrive/c/apps/KDiff3/kdiff3 ...

My .gitconfit

[diff]
    tool = kdiff3
[merge]
    tool = kdiff3
[difftool "kdiff3"]
    cmd = kdiff3 \"$(cygpath -wla $LOCAL)\" \"$(cygpath -wla $REMOTE)\"
    trustExitCode = false
[mergetool "kdiff3"]
    cmd = kdiff3 \"$(cygpath -wla $BASE)\" \"$(cygpath -wla $LOCAL)\" \"$(cygpath -wla $REMOTE)\" -o \"$(cygpath -wla $MERGED)\"
    keepBackup = false
    trustExitCode = false
[mergetool]
    prompt = false
[difftool]
    prompt = false
Ploy answered 14/11, 2014 at 2:5 Comment(0)
P
2

Use git difftool to invoke the configured diff tool, not git diff.

Since you seem to be using cygwin git, but a native kdiff3, you'll probably also need to invoke a wrapper script, rather than kdiff3 directly, to use cygpath convert paths from cygwin form to native form.

Pledget answered 26/2, 2013 at 20:15 Comment(7)
... and Google quickly finds an example of such a scriptPledget
Doing so results in: Viewing: 'file.py' Launch 'kdiff3' [Y/n]: Y After which the tool doesn't launch, I take it the wrapper will resolve this?Stipitate
Using the windows form of the path to kdiff3 seems unlikely to work. Have you tried using the wrapper script?Pledget
OK, I've tried this with the wrapper script. I still get the Launch 'kdiff3' prompt. I respond with Y. Once I do so the response is: "The diff tool kdiff3 is not available as '~/bin/kdiff3.sh'". Note that calling ~/bin/kdiff3.sh successfully starts Kdiff when called on the command line.Stipitate
Hmm.. it seems that page isn't quite right, you can't put ~ in a .gitconfig file, so replace that with /home/jon or whatever your $HOME directory is.Pledget
I made two significant changes to the linked kdiff3.sh script. First to handle embedded spaces in file name: OUT="'!cygpath -wa \"$arg\"!'" (backticks written as ! here...). And secondly avoid making kdiff3 complain when looking at an added/removed file: if [[ "$arg" = "/dev/null" ]]; then arg="/cygdrive/c/some_zero_byte_file"; fi right in front of the OUT=... line.Mast
Adding home directory instead of ~ did not work for me. Am I missing something ? [mergetool "kdiff3"] path = /home/stadikon/kdiff3.sh keepBackup = false trustExitCode = falseBogeyman
O
1
git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global mergetool.kdiff3.keepbackup=false
git config --global mergetool.kdiff3.trustexitcode=false

please check config : git config --global -l

this work fine on cywin 64bit

Orchestra answered 6/10, 2015 at 6:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.