From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: Git never commits, Magit never pushes Date: Sun, 03 Apr 2011 14:45:25 +0530 Message-ID: <81sjtzhf0y.fsf@gmail.com> References: <807hbdceab.fsf@somewhere.org> <80wrjb69je.fsf@somewhere.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1301822618 20563 80.91.229.12 (3 Apr 2011 09:23:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 3 Apr 2011 09:23:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Apr 03 11:23:31 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q6JWs-0007D8-8S for geh-help-gnu-emacs@m.gmane.org; Sun, 03 Apr 2011 11:23:31 +0200 Original-Received: from localhost ([127.0.0.1]:60387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6JWq-0001yT-QJ for geh-help-gnu-emacs@m.gmane.org; Sun, 03 Apr 2011 05:23:28 -0400 Original-Received: from [140.186.70.92] (port=45305 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6JW9-0001tc-I0 for help-gnu-emacs@gnu.org; Sun, 03 Apr 2011 05:22:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6JW3-0002sy-UO for help-gnu-emacs@gnu.org; Sun, 03 Apr 2011 05:22:44 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:34864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6JW3-0002sn-Cp for help-gnu-emacs@gnu.org; Sun, 03 Apr 2011 05:22:39 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q6JVx-000707-LI for help-gnu-emacs@gnu.org; Sun, 03 Apr 2011 11:22:33 +0200 Original-Received: from 115.184.79.146 ([115.184.79.146]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2011 11:22:33 +0200 Original-Received: from kjambunathan by 115.184.79.146 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2011 11:22:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 185 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 115.184.79.146 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) Cancel-Lock: sha1:blZ6pd8nbQAT1GNhNoE/jf63Ym4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:80581 Archived-At: --=-=-= Content-Type: text/plain > Hi Jambunathan, > > Jambunathan K wrote: >> Have you tried vc-git that comes bundled with emacs. > > Now, yes. But it still does not interest me that much, as there is no > interactive diff, which one tool I really need to compare buffers before > committing. I use ediff with git all the time. Put vc-ediff.el (attached with this mail) in the load-path. Add the following code to .emacs. Now "x" on a vc-dir would hide update and unregistered files. (It will only show added/modified files) "C-x C-v =" on a version controlled buffer would launch ediff window. I have been using this setup for a while so I know it works. If something is broken it is possible that I haven't copy/pasted some stuff from my init file. --8<---------------cut here---------------start------------->8--- (require 'vc-ediff) (add-hook 'vc-dir-mode-hook (lambda nil (define-key vc-dir-mode-map "x" 'my-vc-dir-hide-up-to-date))) (defun my-vc-dir-hide-up-to-date () (interactive) (vc-dir-hide-up-to-date) (vc-dir-hide-unregistered)) (defun vc-dir-hide-unregistered () "Hide unregistered items from display." (interactive) (let ((crt (ewoc-nth vc-ewoc -1)) (first (ewoc-nth vc-ewoc 0))) ;; Go over from the last item to the first and remove the ;; unregistered files and directories with no child files. (while (not (eq crt first)) (let* ((data (ewoc-data crt)) (dir (vc-dir-fileinfo->directory data)) (next (ewoc-next vc-ewoc crt)) (prev (ewoc-prev vc-ewoc crt)) ;; ewoc-delete does not work without this... (inhibit-read-only t)) (when (or ;; Remove directories with no child files. (and dir (or ;; Nothing follows this directory. (not next) ;; Next item is a directory. (vc-dir-fileinfo->directory (ewoc-data next)))) ;; Remove files in the unregistered state. (eq (vc-dir-fileinfo->state data) 'unregistered)) (ewoc-delete vc-ewoc crt)) (setq crt prev))))) (defun my-ediff-revision (file rev1 &optional rev2) "Run Ediff by comparing 'master' against the 'current'." (find-file file) (if (and (buffer-modified-p) (y-or-n-p (format "Buffer %s is modified. Save buffer? " (buffer-name)))) (save-buffer (current-buffer))) (ediff-load-version-control) (funcall (intern (format "ediff-%S-internal" ediff-version-control-package)) rev1 rev2 nil)) (defun my-vc-diff (&optional arg) (interactive "P") (call-interactively (cond (arg (lambda nil (interactive) (vc-diff nil))) (t (lambda nil (interactive) (my-ediff-revision (buffer-file-name) (read-string "revision? " "HEAD" nil "HEAD") "")))))) (define-key vc-prefix-map "=" 'my-vc-diff) --8<---------------cut here---------------end--------------->8--- > I did not find yet, though, how to push it to the Git repo. C-x v v commits to the local branch. I generally push to the remote repo from the shell. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=vc-ediff.el Content-Transfer-Encoding: quoted-printable Content-Description: vc-ediff.el ;;; vc-ediff.el --- Replacement for vc-diff ;; Copyright (C) 2004-2010 Sean MacLennan ;; XEmacs ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. (defvar vc-ediff-buffer-list nil "Local variable.") (defvar vc-ediff-delete nil "Local variable.") (eval-when-compile (require 'ediff)) ;; vc-version-other-window does the heavy lifting. ;; Emacs 23 uses vc-revision rather than vc-version. ;; Thanks to Andrew Stein for catching this. (defmacro vc-ediff-version-other-window (rev) (if (and (featurep 'emacs) (>=3D emacs-major-version 23)) '(vc-revision-other-window rev) '(vc-version-other-window rev))) ;;;###autoload (defun vc-ediff (arg) "Like `vc-diff' but performs an `ediff' rather than a `diff'." (interactive "P") (let ((work (current-buffer)) (mode major-mode) (rev "") cvs) (when arg (setq rev (read-string "Revision: "))) (setq vc-ediff-delete nil) (vc-ediff-version-other-window rev) (setq major-mode mode) (setq cvs (current-buffer)) (add-to-list 'vc-ediff-buffer-list cvs) (add-hook 'ediff-quit-hook 'vc-ediff-quit-hook) (add-hook 'ediff-quit-hook 'vc-ediff-cleanup t) (ediff-buffers (buffer-name cvs) (buffer-name work)))) ;; Cleanup the file? (defun vc-ediff-quit-hook () (when (memq ediff-buffer-B vc-ediff-buffer-list) (setq vc-ediff-delete (list ediff-buffer-A ediff-buffer-B)))) (defun vc-ediff-cleanup () (when vc-ediff-delete (switch-to-buffer (car vc-ediff-delete)) (kill-buffer (cadr vc-ediff-delete)) (delete-other-windows) (setq vc-ediff-buffer-list (delq vc-ediff-delete vc-ediff-buffer-list)) (unless vc-ediff-buffer-list (remove-hook 'ediff-quit-hook 'vc-ediff-quit-hook) (remove-hook 'ediff-quit-hook 'vc-ediff-cleanup)) (setq vc-ediff-delete nil) )) (provide 'vc-ediff) --=-=-= Content-Type: text/plain -- --=-=-=--