I'm trying to get my cygwin git installation working with kdiff3.
I followed Noam Lewis' instructions here: http://noamlewis.wordpress.com/2011/03/22/how-to-use-kdiff3-as-a-difftool-mergetool-with-cygwin-git/
But it's not working :(
Running
git mergetool -t kdiff3
Gives this result:
Normal merge conflict for ...
{local}: modified file
{remote}: modified file
Hit return to start merge resolution tool (kdiff3):
The merge tool kdiff3 is not available as '~/kdiff3.sh'
However, running
~/kdiff3.sh
Opens kdiff3 as expected.
Here's my .gitconfig:
[diff]
tool = kdiff3
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = ~/kdiff3.sh
keepBackup = false
trustExitCode = false
kdiff3.sh
#!/bin/sh
RESULT=""
for arg
do
if [[ "" != "$arg" ]] && [[ -e $arg ]];
then
OUT=`cygpath -wa $arg`
else
OUT=$arg
if [[ $arg == -* ]];
then
OUT=$arg
else
OUT="'$arg'"
fi
fi
RESULT=$RESULT" "$OUT
done
/cygdrive/c/Program\ Files\ \(x86\)/KDiff3/kdiff3.exe $RESULT
git mergetool is fully configurable so you can pretty much chose your favourite tool. In brief, you can set a default mergetool by setting the user config variable merge. tool . If the merge tool is one of the ones supported natively by it you just have to set mergetool.
The wrap shell script is not necessary. I'm using kdiff3 installed in windows and set its folder in path and git in cygwin. If you don't set path for kdiff3 you need to give the full path in cmd as cmd = /cygdrive/c/apps/KDiff3/kdiff3 ...
[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
Simple answer is that you can't have a '~' in a git config file (apparently).
So replacing this line:
[mergetool "kdiff3"]
path = ~/kdiff3.sh
With this:
[mergetool "kdiff3"]
path = /home/mike.hadlow/kdiff3.sh
Made it work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With