Cygwin Git: The merge tool kdiff3 is not available
Asked Answered
G

3

5

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
Guffey answered 31/1, 2014 at 15:52 Comment(1)
i have already answer here : #15097553 goodluckBurra
I
6

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
Ical answered 14/11, 2014 at 1:22 Comment(2)
This is essentially the same as Noam Lewis' solution, just inlined in the .gitconfig, using cygpath to convert unix to windows paths. I personally like the script better, as it allows me to call kdiff3 from anywhere in cygwin.Nereidanereids
@dirkjot, Actually, the script is not necessary. You only need to set kdiff3 folder in path then you can use kdiff3 anywhere in cygwin. it just like below: kdiff3 file1 file2Ical
G
3

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.

Guffey answered 31/1, 2014 at 16:1 Comment(0)
Q
0

For me the solution was to change the global .gitconfig file. When running

git config --global -l 

I got this

mergetool.kdiff3.cmd='C:/Program Files (x86)/KDiff3/kdiff3.exe' "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"

which is exactly what it should be. My problem was that I have sourcetree installed and it "hijacked" the tool setting.

my .gitconfig file had the command above under [mergetool "sourcetree"]

changing this line to [mergetool "kdiff3"]

solved the problem.

Quartering answered 31/12, 2015 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.