]> git.eshelyaron.com Git - emacs.git/commitdiff
Find most specific backend for `vc-backend-for-registration'.
authorManuel Giraud <manuel@ledu-giraud.fr>
Sun, 14 Nov 2021 00:51:31 +0000 (01:51 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 14 Nov 2021 00:54:46 +0000 (01:54 +0100)
* 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

index 4b56f1b795cd09ae3a24e87a387870d3c8c85dfb..64f752f248d2e1e82696d3cba064d6dc911e1695 100644 (file)
@@ -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))))