使用 ediff 作为 git mergetool [英] Using ediff as git mergetool

查看:22
本文介绍了使用 ediff 作为 git mergetool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将 ediff 与git mergetool"一起使用.

I would like to be able to use ediff with "git mergetool".

我发现了一些改变源代码的补丁,我不想这样做.相反,我想用我的 .gitconfig 添加 ediff 支持.

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.

我知道 git 内置了对emerge 的支持,但我更喜欢 ediff.

I know git has builtin support for emerge, but I prefer ediff.

我试图将这些行添加到我的 .gitconfig 中:

I attempted to add these lines to my .gitconfig:

[mergetool "ediff"]
    cmd = emacs --eval "(ediff-merge-files-with-ancestor "$LOCAL" "$REMOTE" "$BASE" nil "$MERGED")"

但是当我尝试使用git mergetool --tool=ediff"运行它时,我得到了这个:

But when I try to run this with "git mergetool --tool=ediff", I get this:

eval: 1: Syntax error: "(" unexpected

我做错了什么?

推荐答案

我使用了一个更复杂的命令.据我所知,我是从这个线程中得到的 http://kerneltrap.org/mailarchive/git/2007/6/28/250230(可能与您所指的相同).

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\"))"

请注意,我已将其拆分为多行以提高可读性并使用 转义换行符,因此 git config 将其视为单行.

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.

我通常使用 emacsclient 进行编辑,例如提交消息.不幸的是,上面的 mergetool 配置没有使用 emacsclient,当我试图让它与 emacsclient 一起工作时,我遇到了各种问题,包括 emacsclient 立即返回的事实.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆