diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2007-07-23 05:38:44 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2007-07-23 05:38:44 +0000 |
commit | 4127ed49c36b9df647d5278be28e1307d9b17cc9 (patch) | |
tree | 490fe84dd7b9422e63d9a032fc168ea4c430b21d /lisp/vc-hooks.el | |
parent | 7d56ddc5764b329ff315706e7e2a7eba34e60201 (diff) | |
download | emacs-4127ed49c36b9df647d5278be28e1307d9b17cc9.tar.gz emacs-4127ed49c36b9df647d5278be28e1307d9b17cc9.tar.bz2 emacs-4127ed49c36b9df647d5278be28e1307d9b17cc9.zip |
(vc-find-root): Walk up the tree to find an existing
`file' from which to start the search and fix case where `file' is the
current directory and the root as well.
Diffstat (limited to 'lisp/vc-hooks.el')
-rw-r--r-- | lisp/vc-hooks.el | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 22935ab7f3b..29c827852fb 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -314,22 +314,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-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 |