2

I am using Beyond Compare as my external diff tool. It does not work when I configure it on my new computer in the .gitconfig as I did on other computers. If I specify the extcmd with too many quotes then it does work.

One big difference between now and previous times is that I am using LFS on my new repository.

.gitconfig file:

[diff]
    tool = bc4
    renameLimit = 999999
[difftool]
    prompt = false
[difftool "bc4"]
    cmd = 'C:/Program Files/Beyond Compare 4/BComp.exe' \"$LOCAL\" \"$REMOTE\"

Does not work (with either single or double quotes):

$ git difftool --extcmd='C:/Program Files/Beyond Compare 4/BComp.exe' HEAD
C:/Program Files/Git/mingw64/libexec/git-core\git-difftool--helper: line 62: C:/Program: No such file or directory
fatal: external diff died, stopping at file.cs

Does work:

git difftool --extcmd="'C:/Program Files/Beyond Compare 4/BComp.exe'" HEAD
  1. How can I get it to work so that I can just use git difftool HEAD?

  2. Is Git LFS causing my problems?

  3. Is something else misconfigured on my new computer and that is causing my problems?

I tried changing the single quotes (') in the config to double-quotes (") but that also did not work.

I am using git version 2.29.2.windows.2 on a fresh install of Windows 10.

Edit: forgot to be clear on what "does not work" means: It does not open Beyond Compare, but there is no error message. It just seems to do nothing for several seconds:

$ git difftool HEAD

$

My entire .gitconfig (in case it helps): https://hastebin.com/icuduxecen.ini

Sirius 5
  • 103
  • 9
  • Have you tried "C:\\Program Files\\Beyond Compare 4\\BComp.exe"? Notice the double quotes instead of single quotes and double \ (escape) – Mohana Rao Dec 17 '20 at 04:04
  • Doing that gives: ```$ git difftool --extcmd="C:\\Program Files\\Beyond Compare 4\\BComp.exe" HEAD C:/Program Files/Git/mingw64/libexec/git-core\git-difftool--helper: line 62: C:Program: command not found fatal: external diff died, stopping at file.cs``` – Sirius 5 Dec 17 '20 at 13:11
  • Putting it in the config has the same results as the original setup: does nothing for a few seconds. – Sirius 5 Dec 17 '20 at 13:13

2 Answers2

2

This was actually a bug in git and was fixed in v2.29.2(2).

See https://github.com/git-for-windows/git/issues/2893

Sirius 5
  • 103
  • 9
1

Unless you have a specific reason to specify the full command line to invoke Beyond Compare, specify just the path to the program:

[difftool "bc4"]
    path = "C:/Program Files/Beyond Compare 4/BComp.exe"

Note the double-quotes and forward slashes.

Edit: Be sure to remove the line cmd = (or rename it cmd to xcmdx or something to hide it if you do not want to remove it).

j6t
  • 9,150
  • 1
  • 15
  • 35
  • Same result, `git difftool HEAD` does nothing for a few seconds. – Sirius 5 Dec 17 '20 at 13:50
  • Does `GIT_TRACE=2 git difftool HEAD` offer a clue? – j6t Dec 17 '20 at 15:37
  • Not sure what this is saying: https://hastebin.com/toqokayifi.apache – Sirius 5 Dec 17 '20 at 17:59
  • Nothing conclusive. No glaring delays anywhere. Did you check with `git diff HEAD` (without `tool`) that there actually *are* any changes? – j6t Dec 17 '20 at 18:09
  • You must remove the `cmd` configuration because it has precedence over `path`, I think. – j6t Dec 17 '20 at 18:14
  • yes, `git diff HEAD` shows the changes as expected (also why I am using HEAD instead of just `git diff`, all the changes have been staged). – Sirius 5 Dec 18 '20 at 02:44
  • There is no difftool.bc4.cmd setting now, only the path. I will change the mergetool.bc4.cmd setting also – Sirius 5 Dec 18 '20 at 02:51
  • Solved! Changing the mergetool.bc4.cmd line to mergetool.bc4.path caused git to use vimdiff. Fiddling with it some more resulted in the error `git config option diff.tool set to unknown tool: bc4`. Replacing bc4 with bc everywhere caused it to start working. Both `git difftool HEAD` and `git difftool -d HEAD` now work. Thank you! – Sirius 5 Dec 18 '20 at 03:00
  • I do not understand why it did not work before though. So bc4 is no longer built in, but can't you define a new difftool and set up git to use it? How is that different from what I did? – Sirius 5 Dec 18 '20 at 03:04