9

I used @VonC's excellent instructions to configure my development system so that git difftool <BRANCH1> <BRANCH1> will invoke WinMerge. Here is what I did:

  1. Placed the following in ~/.gitconfig:

    [diff]

    tool = winmerge
    

    [difftool "winmerge"]

    cmd = winmerge.sh \"$LOCAL\" \"$REMOTE\"
    

    [difftool]

    prompt = false
    
  2. Created a /usr/bin/winmerge.sh with the following content:

    echo Launching WinMergeU.exe: $1 $2

    "C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -ub "$1" "$2"

Now, when I try to launch WinMerge via git difftool <BRANCH1> <BRANCH1>, I receive what seems to be correct parameter passing:

Launching WinMergeU.exe: /tmp/21qMVb_file1.c /tmp/1ACqik_file1.c

But, for some strange reason, instead of WinMerge displaying the two files side-by-side, it prompts for entering the first file as the right-side, with the second file accepted as the left-side:

[WinMerge should be displaying 2 files not one

Why is this happening? What did I miss in the configuration steps?

P.S. When I type on the command line winmerge.sh file1.c file2.c, WinMerge immediately displays the two files side-by-side, just as I would expect.

UPDATE: Oh wow, I just noticed the Both paths are invalid message at the bottom of WinMerge's prompt (and updated the screenshot to emphasize that). It appears that these files simply weren't generated by difftool or something is wrong with the path.

Community
  • 1
  • 1
WinWin
  • 7,493
  • 10
  • 44
  • 53
  • 1
    Did you try this variation? http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/4116806#4116806 – VonC Jul 11 '11 at 13:40
  • @VonC Not yet, but note my update which point at the problem being at an earlier point than `winmerge.sh`. It seems to me that the weirdness of my system configuration works against me... `cygwin-1.7.8-1` + `git version 1.7.4` + `Windows 7 Ultimate 64-bit` with my `$HOME=/home` which is mounted as `//sambaserver/projshare` on `/home`. – WinWin Jul 11 '11 at 13:52
  • 1
    any chance to define your `HOME` on a more conventional PATH? `C:\...` Chances are your script works only in a bash environment, not in a Windows one. – VonC Jul 11 '11 at 13:54
  • @VonC I found the solution! :)) See below. – WinWin Jul 11 '11 at 14:02
  • Note: [Git 2.5 is now aware of Winmerge as a diff or merge tool](http://stackoverflow.com/a/30699239/6309) – VonC Jun 07 '15 at 22:54

1 Answers1

6

I solved the problem!

The solution lies in the hint provided by @pydave's answer in the same thread. All I had to do is replace "$1" "$2" (in winmerge.sh) with cygpath -w $1 cygpath -w $2.

It works beautifully now. Just as I would expect.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
WinWin
  • 7,493
  • 10
  • 44
  • 53
  • 2
    Can you add more details to this answer? What does your .gitconfig look like? – dezman Oct 10 '13 at 17:11
  • To work for me the final command to execute in the shell script was like so: "C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -ub -dl other -dr local \`cygpath -aw $1\` \`cygpath -aw $2\` – user470714 Oct 09 '17 at 22:06