From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: vc-find-root and nonexistent drives Date: Sat, 16 Feb 2008 15:33:15 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203194014 7527 80.91.229.12 (16 Feb 2008 20:33:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Feb 2008 20:33:34 +0000 (UTC) Cc: Emacs Devel To: "Juanma Barranquero" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 16 21:33:58 2008 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 1JQTjP-0004qy-VY for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2008 21:33:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JQTiv-0000C8-6C for ged-emacs-devel@m.gmane.org; Sat, 16 Feb 2008 15:33:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JQTip-0000A8-Ox for emacs-devel@gnu.org; Sat, 16 Feb 2008 15:33:19 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JQTin-00007U-Om for emacs-devel@gnu.org; Sat, 16 Feb 2008 15:33:19 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JQTin-00007D-Jt for emacs-devel@gnu.org; Sat, 16 Feb 2008 15:33:17 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JQTin-0002en-98 for emacs-devel@gnu.org; Sat, 16 Feb 2008 15:33:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAIfXtkdMCpRc/2dsb2JhbACsTIEC X-IronPort-AV: E=Sophos;i="4.25,362,1199682000"; d="scan'208";a="14621160" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 16 Feb 2008 15:33:16 -0500 Original-Received: from pastel.home ([76.10.148.92]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id WWX30016; Sat, 16 Feb 2008 15:33:16 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id C01787FCA; Sat, 16 Feb 2008 15:33:15 -0500 (EST) In-Reply-To: (Juanma Barranquero's message of "Sat, 16 Feb 2008 19:09:35 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:89271 Archived-At: > 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)