[英]Ediff as git difftool
I'm trying to use emacs ediff as a git difftool.我正在尝试使用 emacs ediff 作为 git difftool。
I have followed some of the configurations proposed here: Using ediff as git mergetool我遵循了这里提出的一些配置: 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.在比较某个文件的不同 git 修订版时,我完全没有问题:ediff 运行良好,并且正确描述了两个版本之间的差异。
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.但是,当我尝试运行 git difftool 以将文件的当前目录版本与某个 git 修订版进行比较时遇到了问题。 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.我尝试了几个文件,我认为经验法则如下: - 如果要比较的文件没有放在git根目录中,那么它就会失败。 - Otherwise, ediff shows the differences between the current version of the file and the specified revision without any problem.
- 否则,ediff 会显示文件的当前版本与指定修订版之间的差异,没有任何问题。
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.
所有这些都给了我相同的结果:将非根 git 文件的当前目录版本与某个 git 修订版进行比较时, git difftool 失败。
Any idea how this can be fixed?知道如何解决这个问题吗?
Thanks a lot.非常感谢。 -Bob
-鲍勃
Git knows about a number of standard diff/merge tools, including ediff/emerge. Git 知道许多标准的 diff/merge 工具,包括 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. ediffclient
将使用 emacsclient 而不是启动一个新的 emacs,我更喜欢 YMMV。
EDIT (in response to a comment): If git complains about edifftool, try adding the following to your global git config file ( $HOME/.gitconfig
):编辑(回应评论):如果 git 抱怨 edifftool,请尝试将以下内容添加到您的全局 git 配置文件 (
$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).我的印象是这些设置是安装的一部分,但也许我错了(或者可能在更新版本的 git 中发生了变化)。 I'll try to dig a little deeper when I find some time.
当我找到一些时间时,我会尝试更深入地挖掘。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.