From: Manuel Giraud Date: Sun, 14 Nov 2021 00:51:31 +0000 (+0100) Subject: Find most specific backend for `vc-backend-for-registration'. X-Git-Tag: emacs-29.0.90~2852^2~303 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=439a3094ff7fd84d1b1a5c6f5eb87431eec0d7fd;p=emacs.git Find most specific backend for `vc-backend-for-registration'. * lisp/vc/vc.el (vc-backend-for-registration): Count file name components instead of the length of the file name string (bug#50572). --- diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4b56f1b795c..64f752f248d 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -944,8 +944,10 @@ use." bk) (dolist (backend vc-handled-backends) (when (not (vc-call-backend backend 'registered file)) - (let* ((path (vc-call-backend backend 'responsible-p file)) - (len (length path))) + (let* ((dir-name (vc-call-backend backend 'responsible-p file)) + (len (and dir-name + (length (file-name-split + (expand-file-name dir-name)))))) (when (and len (> len max)) (setq max len bk backend))))) (when bk @@ -977,7 +979,7 @@ use." (message "arg %s" arg) (and (file-directory-p arg) (string-prefix-p (expand-file-name arg) def-dir))))))) - (let ((default-directory repo-dir)) + (let ((default-directory repo-dir)) (vc-call-backend bk 'create-repo)) (throw 'found bk))))