emacs-devel
[Top][All Lists]
Advanced

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

Re: vc-find-root and nonexistent drives


From: Stefan Monnier
Subject: Re: vc-find-root and nonexistent drives
Date: Sat, 16 Feb 2008 15:33:15 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> I think you misread my message. What I'm talking about happens before,
> in the first while loop of `vc-find-root'. It is written assuming that
> you can keep taking out parts of a filename until you eventually end
> with a valid directory, because / always exists. But g:/ does not need
> to exist on Windows.

Thanks.  Yes indeed, this initial loop is problematic because it does
not take the precautions that we added to the main loop.

Can you try the patch below?


        Stefan


--- vc-hooks.el.~1.182.2.14.~   2008-01-21 12:15:18.000000000 -0500
+++ vc-hooks.el 2008-02-16 15:30:42.000000000 -0500
@@ -316,11 +316,12 @@
 If WITNESS if not found, return nil, otherwise return the root."
   ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
   ;; witnesses in /home or in /.
-  (while (not (file-directory-p file))
-    (setq file (file-name-directory (directory-file-name file))))
   (setq file (abbreviate-file-name file))
   (let ((root nil)
-        (user (nth 2 (file-attributes file))))
+        ;; `user' is not initialized outside the loop because
+        ;; `file' may not exist, so we may have to walk up part of the
+        ;; hierarchy before we find the "initial UID".
+        (user nil))
     (while (not (or root
                     (null file)
                     ;; As a heuristic, we stop looking up the hierarchy of
@@ -328,7 +329,9 @@
                     ;; to another user.  This should save us from looking in
                     ;; things like /net and /afs.  This assumes that all the
                     ;; files inside a project belong to the same user.
-                    (not (equal user (nth 2 (file-attributes file))))
+                    (let ((prev-user user))
+                      (setq user (nth 2 (file-attributes file)))
+                      (and prev-user (not (equal user prev-user))))
                     (string-match vc-ignore-dir-regexp file)))
       (if (file-exists-p (expand-file-name witness file))
           (setq root file)




reply via email to

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