gitwinmergegit-difftool

How to debug git difftool command ( WinMerge , git on windows)


I have spend some time to configure git (git version 2.35.3.windows.1) to use WinMerge (2.16.20) as a external difftool. This post was my entry point and this Gist seem to help some people. Still no luck on my side.

$ git config --global --list
  ...
  diff.tool=winmerge
  difftool.winmerge.prompt=false
  difftool.winmerge.trustexitcode=true
  difftool.winmerge.cmd=.... (different versions see below)
--------------------------------------------------------------------------------
Example
cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e $LOCAL $REMOTE  
cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" -u -e \"$LOCAL\" \"$REMOTE\"

Question 1: In the post the author refers to version 2.5 of git. But the official repo list 2.36 as lastest release. There seems to be a 2.5 release from 2015 for windows. Is that experimental? Or not official?

Question 2: Can somebody explain to what git difftool is doing behing the scenes? Is there a way to simulate the call outside of git, so I could debug it better? Maybe someone also had this problem an could explain how he debugged the problem

I have no error message (seems to get swallowd ...)


Solution

  • It's a nightmare to write correct spaces, slashes and backslashes of Windows paths in gitconfig. To avoid it, add c:\Program Files (x86)\WinMerge to the system variable Path (google windows how to edit system variables) so that we can invoke an executable (WinMergeU.exe in your case) under the paths directly in the command line instead of its absolute path.

    After updating Path, reopen git-bash to reload it. Run git config --global -e to edit difftool.winmerge.cmd

    [difftool "winmerge"]
        cmd = WinMergeU.exe -u -e "$LOCAL" "$REMOTE"
    

    To test if it works, enter a git repository and run git difftool HEAD^ HEAD. You can try other git diff commands, replacing git diff with git difftool.