使用 ediff 作为 git mergetool

编程入门 行业动态 更新时间:2024-10-26 00:32:08
本文介绍了使用 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/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-30 20:19:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/787586.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ediff   git   mergetool

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!