External Diff does not work.
Asked by fredzvt:

External Diff does not work, any ideas why? Is this a bug?

I'm using SourceTree 3.4.13 on Windows 10 Pro.

On my .gitconfig I have:

```
[difftool "sourcetree"]
cmd = 'D:/Program Files (x86)/WinMerge/WinMergeU.exe' \"$LOCAL\" \"$REMOTE\"
```

The path to WinMerge is correct.

And here is the GetExternalDiffProcess process log:

```
{
"Command": "git\r\n-c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks difftool -y --tool=sourcetree --\r\nAssets/DrestPrototype/Prefabs/UI/Tasks/Game Task.prefab",
"Directory": "D:\\Documents\\Projects\\Droid\\Unity_Prototype",
"Status": "Finished",
"Duration": "00:00:00.0651253",
"CallerContext": "GetExternalDiffProcess",
"Output": "warning: LF will be replaced by CRLF in Assets/DroidPrototype/Prefabs/UI/Tasks/Game Task.prefab.\nThe file will have its original line endings in your working directory\n"
}
```

The command has break lines and it looks completely wrong.


Answers:
author: Stew Stryker
body: Has it ever worked for you? I'm on 3.4.14, but it's worked for me since Day 2.

My .gitconfig shows:  

```
[difftool "bc3"]

    path = C:/Program Files (x86)/Beyond Compare 3/bcomp.exe

    cmd = \"C:/Program Files (x86)/Beyond Compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\"

```

Hope this helps.


author: fredzvt
body: Updated SourceTree to 3.4.14. Same behaviour.

comments: author: Stew Stryker
body: That's why I said it had worked for me since Day 2. I should have also included this definition:

```
[difftool "sourcetree"]
cmd = 'C:/Program Files (x86)/Beyond Compare 3/BComp.exe' \"$LOCAL\" \"$REMOTE\"
```

I don't see that it's any different from yours, except a different tool.

Looking at your Process Log, the "--tool=" reference makes me think you need to define your compare tool at the Git level???

I don't remember doing that and I don't use the command line much, so just a WAG.

Good luck.


author: fredzvt
body: Hi, Stew!  

No, it never worked for me, but I'd love to make this work.  

Regarding defining the tool at the git level. The log shows up --tool=sourcetree. Isn't it correct?  

What I think is the problem are those weird break lines in the command. I don't know if there is a way to remove these break lines in some configuration file.

```
"Command": "git\r\n-c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks difftool -y --tool=sourcetree --\r\nAssets/DrestPrototype/Prefabs/UI/Tasks/Game Task.prefab"
```


author: fredzvt
body: I just found out [this other question](https://community.atlassian.com/t5/Sourcetree-questions/Bitbucket-breaks-diff-and-mergetool-commands-in-gitconfig-by/qaq-p/2271707) and I tried to change the single quotes for escaped double quotes on .gitconfig and it worked!  

So, instead of

```
[difftool "sourcetree"]
cmd = 'D:/Program Files (x86)/WinMerge/WinMergeU.exe' \"$LOCAL\" \"$REMOTE\"
```

I have now

```
[difftool "sourcetree"]
cmd = \"d:/Program Files (x86)/WinMerge/WinMergeU.exe\" \"$LOCAL\" \"$REMOTE\"
```

<br />

But I have the same problem as Jason in his question. If I open Tools \> Options it rewrites .gitconfig and the External Diff command doesn't anymore again. Really annoying!


Tags: server