From 3b27900d2a4f84f5a826a59b7b0e544ffca5f0e7 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 20 Jul 2007 03:48:27 +0000 Subject: [PATCH] (vc-find-root): Fix case where `file' is the current directory and the root as well. --- lisp/ChangeLog | 8 ++++++-- lisp/vc-hooks.el | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8f5460ef4d7..079e14914b3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-07-20 Stefan Monnier + + * vc-hooks.el (vc-find-root): Fix case where `file' is the current + directory and the root as well. + 2007-07-20 Dan Nicolaescu * vc-hooks.el (vc-default-workfile-unchanged-p): Pass a list @@ -5,8 +10,7 @@ * vc-hg.el (vc-hg-print-log): Deal with multiple file arguments. (vc-hg-registered): Replace if with when. - (vc-hg-state): Deal with nonexistent files and handle removed - files. + (vc-hg-state): Deal with nonexistent files and handle removed files. (vc-hg-dir-state, vc-hg-dired-state-info): New functions. (vc-hg-checkout): Re-enable. (vc-hg-create-repo): Fix typos. diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 83f9903e664..cbbfd8e7e22 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -317,24 +317,25 @@ The function walks up the directory tree from FILE looking for WITNESS. 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-exists-p file)) + (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)))) (while (not (or root - (equal file (setq file (file-name-directory file))) - (null file) - ;; As a heuristic, we stop looking up the hierarchy of - ;; directories as soon as we find a directory belonging - ;; 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)))) - (string-match vc-ignore-dir-regexp file))) + (null file) + ;; As a heuristic, we stop looking up the hierarchy of + ;; directories as soon as we find a directory belonging + ;; 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)))) + (string-match vc-ignore-dir-regexp file))) (if (file-exists-p (expand-file-name witness file)) - (setq root file) - (setq file (directory-file-name file)))) + (setq root file) + (if (equal file + (setq file (file-name-directory (directory-file-name file)))) + (setq file nil)))) root)) ;; Access functions to file properties -- 2.39.2