From: Theodore Tso Subject: Re: [PATCH] git-mergetool: add support for ediff Date: Mon, 2 Jul 2007 18:16:39 -0400 Message-ID: <20070702221639.GB20597@thunk.org> References: <11830788163411-git-send-email-sam.vilain@catalyst.net.nz> <31e9dd080706281831vbe24597i9b6a5f6f6db6fec8@mail.gmail.com> <20070629040328.GG29279@thunk.org> <20070702020401.GD28917@thunk.org> <46896EF2.70006@vilain.net> <20070702215859.GA20597@thunk.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jason Sewall , Junio C Hamano , git@vger.kernel.org To: Sam Vilain X-From: git-owner@vger.kernel.org Tue Jul 03 00:16:54 2007 connect(): Connection refused Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1I5UCT-0007DY-La for gcvg-git@gmane.org; Tue, 03 Jul 2007 00:16:53 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756935AbXGBWQq (ORCPT ); Mon, 2 Jul 2007 18:16:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756879AbXGBWQq (ORCPT ); Mon, 2 Jul 2007 18:16:46 -0400 Received: from THUNK.ORG ([69.25.196.29]:37740 "EHLO thunker.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756820AbXGBWQp (ORCPT ); Mon, 2 Jul 2007 18:16:45 -0400 Received: from root (helo=candygram.thunk.org) by thunker.thunk.org with local-esmtps (tls_cipher TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.50 #1 (Debian)) id 1I5UK7-0006fl-PI; Mon, 02 Jul 2007 18:24:48 -0400 Received: from tytso by candygram.thunk.org with local (Exim 4.63) (envelope-from ) id 1I5UCF-0000zT-Go; Mon, 02 Jul 2007 18:16:39 -0400 Content-Disposition: inline In-Reply-To: <20070702215859.GA20597@thunk.org> User-Agent: Mutt/1.5.13 (2006-08-11) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on thunker.thunk.org); SAEximRunCond expanded to false Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: OK, so I've hacked together the following emacs-lisp snippet, which I propose would go in contrib/use-ediff-instead.el. If placed in your .emacs.el file, it will cause you to use ediff instead of emerge when you call "git mergetool". It does so by replacing the two functions emerge-files-command and emerge-files-with-ancestor-comand with ones that patch the necessary ediff hooks, and then calling the ediff package instead of the emerge package. With this .el file, no changes are needed to git-mergetool.sh. Does this meet your needs? - Ted ;; use-ediff-instead.el ;; ;; This emacs lisp snippet should be placed in your .emacs.el file in ;; order to use the ediff package instead of emerge for git-mergetool. ;; Ediff has more whiz-bang features, but unfortunately it doesn't ;; integrate well with shell scripts that try to invoke ediff from an ;; emacs shell invocation. (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))) (defun emerge-files-command () (let ((file-a (nth 0 command-line-args-left)) (file-b (nth 1 command-line-args-left)) (file-out (nth 2 command-line-args-left))) (setq command-line-args-left (nthcdr 3 command-line-args-left)) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files file-a file-b nil file-out))) (defun emerge-files-with-ancestor-command () (let (file-a file-b file-anc file-out) ;; check for a -a flag, for filemerge compatibility (if (string= (car command-line-args-left) "-a") ;; arguments are "-a ancestor file-a file-b file-out" (progn (setq file-a (nth 2 command-line-args-left)) (setq file-b (nth 3 command-line-args-left)) (setq file-anc (nth 1 command-line-args-left)) (setq file-out (nth 4 command-line-args-left)) (setq command-line-args-left (nthcdr 5 command-line-args-left))) ;; arguments are "file-a file-b ancestor file-out" (setq file-a (nth 0 command-line-args-left)) (setq file-b (nth 1 command-line-args-left)) (setq file-anc (nth 2 command-line-args-left)) (setq file-out (nth 3 command-line-args-left)) (setq command-line-args-left (nthcdr 4 command-line-args-left))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor file-a file-b file-anc nil file-out))) ;; End of use-ediff-instead.el