Using ediff as git mergetool

前端 未结 12 488
天命终不由人
天命终不由人 2020-12-12 10:22

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 ed

12条回答
  •  囚心锁ツ
    2020-12-12 11:09

    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 ;-)

提交回复
热议问题