mbinic / vscode-tgit

TortoiseGit commands for Visual Studio Code
MIT License
9 stars 2 forks source link

Fails on WSL Linux-filesystem paths #13

Closed ses4j closed 3 years ago

ses4j commented 4 years ago

I increasingly have to do work on Windows under WSL. Trying to run, eg, tgit.diff with a file mounted on the Linux filesystem doesn't work, unsurprisingly. It is theoretically possible, because any WSL path can be converted to a Windows path. One approach is to use the wslpath command. For instance, for me to get Beyond Compare to work as a git difftool I use this:

[difftool "bc3"]
        # old way 
        # cmd = \"c:/Program Files/Beyond Compare 4/BCompare.exe\" \"$LOCAL\" \"$REMOTE\" -solo
        # new way that supports WSL
        cmd="/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BComp.exe" "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" -solo

Here's wslpath in action:


user@sheyn:~/wc/ventus$ wslpath
wslpath: Invalid argument
Usage:
    -a    force result to absolute path format
    -u    translate from a Windows path to a WSL path (default)
    -w    translate from a WSL path to a Windows path
    -m    translate from a WSL path to a Windows path, with '/' instead of '\'

EX: wslpath 'c:\users'
user@sheyn:~/wc/ventus$ wslpath -aw ~
\\wsl$\Ubuntu\home\user```
mbinic commented 4 years ago

Thanks for the detailed report @ses4j! I agree, wslpath looks promising. I'll give it a shot over the weekend, and release an update if it pans out. Don't hesitate to beat me to it though ;)

ses4j commented 3 years ago

@mbinic Any luck? Or, I haven't looked closely at your code, any suggestion as to where/how this change would be made?

mbinic commented 3 years ago

Sorry @ses4j , busy days... Looking more closely at this, it appears to be the same root cause as issue #2 - trying to start TortoiseGitProc with the working directory set to a network path, i.e. one starting with \.

I've made a small change in the run method on line 109 of src/TGit.ts, to always supply the path argument instead of passing the cwd parameter to exec. I'll test it some more and release an update if it works out.

mbinic commented 3 years ago

Version 1.4.0 released, this should now be fixed. @ses4j, please let me know if everything's ok at your end and I can close this issue.