使用ediff作为git mergetool [英] Using ediff as git mergetool
问题描述
我想使用ediff与git mergetool。
我发现一些修改源代码的补丁,我不想做。相反,我想使用.gitconfig添加ediff支持。
我知道git有内置的支持,但我喜欢ediff。
我试图将这些行添加到我的.gitconfig中:
[mergetoolediff]
cmd = emacs --eval(ediff-merge-files-with-ancestor \$ LOCAL\\$ REMOTE\\$ BASE\nil \$ MERGED\)
但是当我尝试使用git mergetool --tool = ediff,我得到这个:
eval:1:语法错误:(意外
我做错了什么?
我使用一个更复杂的命令,据我所知,我从这个线程得到它 http://kerneltrap.org/mailarchive/git/2007/6/28/250230 (可能与您所指的相同)。
[merget ool.ediff]
cmd = emacs --eval \\
(progn\
(defun ediff-write-merge-buffer()\
((文件ediff-merge-store-file))\
(set-buffer ediff-buffer-C)\
(write-region(point-min)(point-max) \
(消息\\\合并缓冲区保存在:%s\\\文件)\
(set-buffer-modified-p nil)\
(sit-for 1)))\
(setq ediff-quit-hook'kill-emacs\
ediff-quit-merge-hook'ediff-write-merge-buffer) \
(ediff-merge-files-with-ancestor \\\$ LOCAL\\\\\\\$ REMOTE\\\\
\\\$ BASE\\\nil \\\$ MERGED\\\))\
$ c请注意,我已经分割了几行,以提高可读性,并以 \ $ c转义换行符。 $ c>所以git config认为它是一行。
我通常使用emacsclient来编辑例如提交邮件上面的mergetool配置不幸的是没有使用emacsclient,当我试图让它与emacsclient一起工作时,我遇到了各种问题,包括emacsclient马上返回的事实。
I would like to be able to use ediff with "git mergetool".
I found some patches that alter the source code, which I don't want to do. Instead, I'd like to add ediff support with my .gitconfig.
I know git has builtin support for emerge, but I prefer ediff.
I attempted to add these lines to my .gitconfig:
[mergetool "ediff"]
cmd = emacs --eval "(ediff-merge-files-with-ancestor \"$LOCAL\" \"$REMOTE\" \"$BASE\" nil \"$MERGED\")"
But when I try to run this with "git mergetool --tool=ediff", I get this:
eval: 1: Syntax error: "(" unexpected
What am I doing wrong?
解决方案 I use a a more complicated command. As far as I remember I got it from this thread http://kerneltrap.org/mailarchive/git/2007/6/28/250230 (probably the same as what you are referring to).
[mergetool.ediff]
cmd = emacs --eval \"\
(progn\
(defun ediff-write-merge-buffer ()\
(let ((file ediff-merge-store-file))\
(set-buffer ediff-buffer-C)\
(write-region (point-min) (point-max) file)\
(message \\\"Merge buffer saved in: %s\\\" file)\
(set-buffer-modified-p nil)\
(sit-for 1)))\
(setq ediff-quit-hook 'kill-emacs\
ediff-quit-merge-hook 'ediff-write-merge-buffer)\
(ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\"\
\\\"$BASE\\\" nil \\\"$MERGED\\\"))\"
Note that I have split this across several lines to increase readability and escaped the newline with \
so git config considers it as a single line.
I usually use emacsclient to edit e.g. commit messages. The above mergetool configuration unfortunately does not use emacsclient, and when I tried to get it to work with emacsclient I ran in to various problems including the fact that emacsclient returned right away.
But you just reminded me of that issue, so I might work on fixing that problem soon. However if someone else already found a solution that would be great of course ;-)
这篇关于使用ediff作为git mergetool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!