Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ediff as git mergetool

Tags:

git

merge

emacs

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?

like image 882
alternative Avatar asked Nov 30 '09 00:11

alternative


People also ask

What do I do after git Mergetool?

It's generally best to take that message and add any extra information rather than write your own from scratch. Developers who use git will automatically recognize git's merge commits but may not recognize your custom merge messages immediately.

What is a Mergetool?

The Merge Tool combines data from multiple sources, then adds them into a new data set. It's not only geometry, but it also merges attributes with the option to match fields from input datasets. When you use the Merge Tool, features have to be the same geometry type (points, lines, or polygons).


1 Answers

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

like image 168
tarsius Avatar answered Sep 21 '22 21:09

tarsius