all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Juanma Barranquero" <lekktu@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: vc-find-root and nonexistent drives
Date: Sat, 16 Feb 2008 15:33:15 -0500	[thread overview]
Message-ID: <jwvabm0k5he.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <f7ccd24b0802161009o540abc38m16a16580858dbba3@mail.gmail.com> (Juanma Barranquero's message of "Sat, 16 Feb 2008 19:09:35 +0100")

> 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	other threads:[~2008-02-16 20:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-16  3:52 vc-find-root and nonexistent drives Juanma Barranquero
2008-02-16 13:43 ` Eli Zaretskii
2008-02-16 18:12   ` Juanma Barranquero
2008-02-16 20:16     ` Stefan Monnier
2008-02-16 20:18       ` Juanma Barranquero
2008-02-16 14:29 ` Stefan Monnier
2008-02-16 18:09   ` Juanma Barranquero
2008-02-16 20:33     ` Stefan Monnier [this message]
2008-02-16 20:46       ` Juanma Barranquero
2008-02-17  4:18       ` Eli Zaretskii
2008-02-17 19:00         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvabm0k5he.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.