WinMerge via git difftool keeps prompting for second file
Asked Answered
F

1

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.

Franconian answered 11/7, 2011 at 13:16 Comment(5)
Did you try this variation? #255702Bernabernadene
@Bernabernadene 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.Franconian
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.Bernabernadene
@Bernabernadene I found the solution! :)) See below.Franconian
Note: Git 2.5 is now aware of Winmerge as a diff or merge toolBernabernadene
F
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.

Franconian answered 11/7, 2011 at 14:0 Comment(2)
Can you add more details to this answer? What does your .gitconfig look like?Tertius
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`Northerner

© 2022 - 2024 — McMap. All rights reserved.