Ediff as git difftool
Asked Answered
A

1

8

I'm trying to use emacs ediff as a git difftool.

I have followed some of the configurations proposed here: Using ediff as git mergetool

When it comes to comparing between different git revisions of a certain file, I have not problem at all: ediff works well and the differences between both versions are depicted properly.

However, I'm having problems when I try to run git difftool to compare the current directory version of a file with a certain git revision. For some files, I'm getting the following error:

apply: Wrong type argument: arrayp, nil

It is weird, because this error only comes for certain files, not all of them.

I have experimented with several files, and I think that the rule of thumb is as follows: - If the file to be compared is not placed in the git root directory, then it fails. - Otherwise, ediff shows the differences between the current version of the file and the specified revision without any problem.

I have tried with some of the configurations explained in the link I referred to above. All of them give me the same result: git difftool fails when comparing the current directory version of a non-root git file with a certain git revision.

Any idea how this can be fixed?

Thanks a lot. -Bob

Algetic answered 23/8, 2016 at 8:57 Comment(1)
Well, yes, I know meld, but I prefer ediff since it is part of my workflow. I also use magit inside emacs, and it works perfectly. But there are sometimes when I want to launch a diff immediately, without getting into magit, and that is why I need ediff.Algetic
K
10

Git knows about a number of standard diff/merge tools, including ediff/emerge. Try

git config --global diff.tool ediff

and invoke it with

git difftool --tool=ediffclient master -- <file>

or similar. ediffclient will use emacsclient and not start a new emacs, which I prefer but YMMV.

EDIT (in response to a comment): If git complains about edifftool, try adding the following to your global git config file ($HOME/.gitconfig):

[difftool "ediff"]
          cmd = emacs --eval \"(ediff-files \\\"$LOCAL\\\" \\\"$REMOTE\\\")\"
[difftool "ediffclient"]
          cmd = emacsclient --eval \"(ediff-files \\\"$LOCAL\\\" \\\"$REMOTE\\\")\"

I was under the impression that these settings are part of the installation but maybe I'm wrong (or maybe that changed in a more recent version of git). I'll try to dig a little deeper when I find some time.

Knotting answered 6/3, 2017 at 22:5 Comment(5)
Thanks. I've tried what you said and it works fine. RegardsAlgetic
Sorry about that. I completely forgot it... ThanksAlgetic
Unknown merge tool ediffclient fatal: external diff died, stoppingWretch
@Christoph90: Please let me know if the edit helps - thanks!Knotting
Yes, including these lines in .gitconfig made it work for me. The config previously only had my name and E-Mail and ediff as diff tool set. ThanksWretch

© 2022 - 2024 — McMap. All rights reserved.