emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vc-register complains if a file is already registered in a git repos


From: Phil Hagelberg
Subject: Re: vc-register complains if a file is already registered in a git repository
Date: Tue, 21 Oct 2008 15:23:49 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Stefan Monnier <address@hidden> 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 <foo> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]