WinMerge / winmerge

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
https://winmerge.org/
GNU General Public License v2.0
6.44k stars 798 forks source link

Re-think slashed arguments to make usage in WSL more straightforward #877

Open CmdQ opened 3 years ago

CmdQ commented 3 years ago

I'd like to use WinMerge from the WSL2 terminal and have set it up as diff and merge tool.

[difftool "winmerge"]
    name = WinMerge
    cmd = WinMergeU.exe -u -e -xq -wl \"$LOCAL\" \"$REMOTE\"
    trustExitCode = true

I think it used to work before but not it doesn't. It does understand the hyphens but it thinks that the leading slash of a file path is meant to be an option:

WinMerge: Unknown option '/tmp/3bhsve_not_an_option.py'

As the files are only positional arguments only, I did not find a way to force an argument to be interpreted as path.

I tried

  1. transforming the path with wslpath -am but that still begins with a slash
  2. transforming the path with wslpath -aw but the shell doesn't like the backslashes and it totally breaks

I do almost all my work in WSL and it would be really nice to occasionally run a simple git difftool with WinMerge.

Could you provide a way to force interpretation as path? Or alternatively not error out if a given “option” happens to be an existing file.

sdottaka commented 3 years ago

I am not familiar with git and wsl, but the following configuration appeared to work.

[~/.gitconfig]

[difftool "winmerge"]
        name = WinMerge
        cmd = /mnt/c/Program\\ Files/WinMerge/WinMergeU.exe -u -e -xq -wl \"$(wslpath -aw $LOCAL)\" \"$(wslpath -aw $REMOTE)\"
        trustExitCode = true

$ git difftool --tool=winmerge

image

CmdQ commented 3 years ago

Git in WSL is just like in a “real” Linux.

I'm fairly sure I had your configuration already, but with additional inner quotes. But now even that works—confused.

So yes, you've presented a workable solution. What I don't like about it is that it is specific to WSL and I'd need a different config for a Windows/Mac/Linux machine at home.

I just thought there are probably a lot of people using WSL nowadays and it would be great if WinMerge acknowledged that by understanding linux paths.