{"thread":{"id":"39274","subject":"git difftool and proper path escaping on windows","startedAt":"2015-05-08T17:31:05Z","lastAt":"2015-05-10T21:09:58Z","messageCount":3,"participants":["Phil Susi","David Aguilar","Philip Oakley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"260826","messageId":"554CF2D9.3050608@gmail.com","threadId":"39274","inReplyTo":null,"subject":"git difftool and proper path escaping on windows","fromName":"Phil Susi","fromEmail":"phillsusi@gmail.com","sentAt":"2015-05-08T17:31:05Z","receivedAt":"2015-05-08T17:31:05Z","isPatch":false,"sender":{"key":"phillsusi@gmail.com","avatar":null},"body":"I'm trying to have git difftool run winmerge to compare files, but it \nseems to be doing something silly with path translation.  My first \nattempt was:\n\ngit difftool -x /c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe\n\nTo which it responded:\n\nC:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n  eval: line 61: syntax error near unexpected token `('\n\nC:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n  eval: line 61: `c:/Program Files (x86)/WinMerge/WinMergeU.exe \"$LOCAL\" \n\"$REMOTE\n\n\nMy first thought was that my shell removed the backslash escapes and \nthen git tried to pass the remaining command to another shell.  So I \nwrapped the path in single quotes, which should pass the escapes to git, \nwhich should pass them to the shell, which should then be able to parse \nthe spaces in parenthesis in the path, but instead I got this:\n\nLaunch 'c:/Program/ Files/ /(x86/)/WinMerge/WinMergeU.exe'\n\nSo it appears that git is replacing backslashes with forward slashes, \nthen trying to pass that to the shell, which doesn't work.  Any idea how \nto fix or workaround this bug?\n"},{"id":"260943","messageId":"F14B985A-C968-445A-A3F7-10AE425E7029@gmail.com","threadId":"39274","inReplyTo":"554CF2D9.3050608@gmail.com","subject":"Re: git difftool and proper path escaping on windows","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-05-10T20:15:22Z","receivedAt":"2015-05-10T20:15:22Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On May 8, 2015 10:31:05 AM PDT, Phil Susi <phillsusi@gmail.com> wrote:\n>I'm trying to have git difftool run winmerge to compare files, but it \n>seems to be doing something silly with path translation.  My first \n>attempt was:\n>\n>git difftool -x /c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe\n>\n>To which it responded:\n>\n>C:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n>  eval: line 61: syntax error near unexpected token `('\n>\n>C:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n>eval: line 61: `c:/Program Files (x86)/WinMerge/WinMergeU.exe \"$LOCAL\" \n>\"$REMOTE\n>\n>\n>My first thought was that my shell removed the backslash escapes and \n>then git tried to pass the remaining command to another shell.  So I \n>wrapped the path in single quotes, which should pass the escapes to\n>git, \n>which should pass them to the shell, which should then be able to parse\n>\n>the spaces in parenthesis in the path, but instead I got this:\n>\n>Launch 'c:/Program/ Files/ /(x86/)/WinMerge/WinMergeU.exe'\n>\n>So it appears that git is replacing backslashes with forward slashes, \n>then trying to pass that to the shell, which doesn't work.  Any idea\n>how \n>to fix or workaround this bug?\n\n\npaths and executing external programs on windows is confusing and error-prone for a simple unix user such as myself. \n\nI think you might be able to work around the difficulties by making the tool available in your $PATH, that way you don't have to play shell quoting / escaping games. \n\nI hope that helps. if you discover a different solution, I'd be happy to document it so that windows users don't have to rediscover how to do it in the future.\n\nlet me know how it goes. \ncheers\n\n\n-- \nDavid\n"},{"id":"260944","messageId":"303F4B003829461AB3D516B1837C17E1@PhilipOakley","threadId":"39274","inReplyTo":"F14B985A-C968-445A-A3F7-10AE425E7029@gmail.com","subject":"Re: git difftool and proper path escaping on windows","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2015-05-10T21:09:58Z","receivedAt":"2015-05-10T21:09:58Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"David Aguilar\" <davvid@gmail.com>\n> On May 8, 2015 10:31:05 AM PDT, Phil Susi <phillsusi@gmail.com> wrote:\n>>I'm trying to have git difftool run winmerge to compare files, but it\n>>seems to be doing something silly with path translation.  My first\n>>attempt was:\n>>\n>>git difftool -x /c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe\n>>\n>>To which it responded:\n>>\n>>C:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n>>  eval: line 61: syntax error near unexpected token `('\n>>\n>>C:\\Users\\psusi\\AppData\\Local\\Programs\\Git/libexec/git-core\\git-difftool--helper:\n>>eval: line 61: `c:/Program Files (x86)/WinMerge/WinMergeU.exe \"$LOCAL\"\n>>\"$REMOTE\n>>\n>>\n>>My first thought was that my shell removed the backslash escapes and\n>>then git tried to pass the remaining command to another shell.  So I\n>>wrapped the path in single quotes, which should pass the escapes to\n>>git,\n>>which should pass them to the shell, which should then be able to \n>>parse\n>>\n>>the spaces in parenthesis in the path, but instead I got this:\n>>\n>>Launch 'c:/Program/ Files/ /(x86/)/WinMerge/WinMergeU.exe'\n>>\n>>So it appears that git is replacing backslashes with forward slashes,\n>>then trying to pass that to the shell, which doesn't work.  Any idea\n>>how\n>>to fix or workaround this bug?\n>\n>\n> paths and executing external programs on windows is confusing and \n> error-prone for a simple unix user such as myself.\n>\n> I think you might be able to work around the difficulties by making \n> the tool available in your $PATH, that way you don't have to play \n> shell quoting / escaping games.\n>\n> I hope that helps. if you discover a different solution, I'd be happy \n> to document it so that windows users don't have to rediscover how to \n> do it in the future.\n>\n> let me know how it goes.\n> cheers\n>\nA quick web browse found https://gist.github.com/shawndumas/6158524 as \none example of a winmerge configuration.\n\nmy personal .gitconfig has\n[difftool \"WinMerge\"]\n path = C:/Program Files/WinMerge/WinMergeU.exe\n cmd = 'C:/Program Files/WinMerge/WinMergeU.exe' /e /x /u $LOCAL $REMOTE\n[mergetool \"WinMerge\"]\n path = C:/Program Files/WinMerge/WinMergeU.exe\n cmd = 'C:/Program Files/WinMerge/WinMergeU.exe' /e /x /u $LOCAL $REMOTE \n$MERGED\n trustExitCode = false\n\n(excuse whitespace damage)\nthough I don't use it much. \n"}]}