From 439a3094ff7fd84d1b1a5c6f5eb87431eec0d7fd Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Sun, 14 Nov 2021 01:51:31 +0100 Subject: [PATCH] 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). --- lisp/vc/vc.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)))) -- 2.39.2