From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Phil Hagelberg Newsgroups: gmane.emacs.devel Subject: Re: vc-register complains if a file is already registered in a git repository Date: Tue, 21 Oct 2008 15:23:49 -0700 Message-ID: <873aipmvt6.fsf@hagelb.org> References: <87prlvm2ms.fsf@hagelb.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1224627849 19228 80.91.229.12 (21 Oct 2008 22:24:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 22:24:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 22 00:25:10 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KsPf0-0005JC-TQ for ged-emacs-devel@m.gmane.org; Wed, 22 Oct 2008 00:25:07 +0200 Original-Received: from localhost ([127.0.0.1]:46353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsPdv-0003wS-D1 for ged-emacs-devel@m.gmane.org; Tue, 21 Oct 2008 18:23:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsPdr-0003vz-V9 for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:23:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsPdq-0003vA-Ja for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:23:55 -0400 Original-Received: from [199.232.76.173] (port=34075 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsPdq-0003v7-Gr for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:23:54 -0400 Original-Received: from balanced.mail.policyd.dreamhost.com ([208.97.132.119]:38411 helo=spunkymail-a12.g.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KsPdq-0003sE-3u for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:23:54 -0400 Original-Received: from dynabook (unknown [63.229.31.77]) by spunkymail-a12.g.dreamhost.com (Postfix) with ESMTP id 850637FAB; Tue, 21 Oct 2008 15:23:49 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Tue, 21 Oct 2008 17:43:37 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104793 Archived-At: Stefan Monnier writes: >> Unfortunately when I use vc-register on a file that is already in the >> repository, it complains, saying "This file is already registered". This >> is a reasonable thing to do in most VC systems, but git behaves >> differently since it's a common thing to want to register the changes >> you've just made to the git index (or staging area). > > I'm not sure we want to allow C-x v i to do that. OT1H it might be > convenient and maybe it can work well, but OTOH it looks risky and would > require changing vc-register more than I'd like. I just noticed the existence of the vc-default-could-register function: Return non-nil if BACKEND could be used to register FILE. It seems like vc-register should be running this function instead of vc-registered to check if it should continue, like this: diff --git a/lisp/vc.el b/lisp/vc.el index 35e846d..75189e5 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -1206,11 +1206,10 @@ first backend that could register the file is used." (dolist (fname files) (let ((bname (get-file-buffer fname))) (unless fname (setq fname buffer-file-name)) - (when (vc-backend fname) - (if (vc-registered fname) - (error "This file is already registered") - (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") - (error "Aborted")))) + (let ((backend (vc-backend fname))) + (if (and backend + (not (vc-call-backend backend 'could-register fname))) + (error "This file cannot be registered"))) ;; Watch out for new buffers of size 0: the corresponding file ;; does not exist yet, even though buffer-modified-p is nil. But in most backends, vc-BACKEND-could-register only checks to make sure the containing directory is being tracked rather than checking to make sure the file isn't already registered, so you're right that it would require significant changes. Since we're in a feature freeze, perhaps this is ill-advised? > It would probably be better for vc-git to provide another command, for that. > We could probably add a `extra-keys' operation similar to `extra-menu' > so that vc-git can not only provide a new command but also provide > a specific C-x v key binding for it. This would be great if we don't want to make the changes above. I can add it. Could I get some details about extra-menu though? I'm not familiar with it. -Phil http://technomancy.us