(project-try-vc): When found non-VC project root, still search for the backend

* lisp/progmodes/project.el (project-try-vc): When finding a
non-VC project root, still try to search for the containing
responsible VC backend, if any (bug#65704).
This commit is contained in:
Dmitry Gutov 2023-09-06 23:30:27 +03:00
parent dd818ed821
commit 62229fb2d1
3 changed files with 14 additions and 0 deletions

View file

@ -797,6 +797,13 @@ the current project.
The look of the key prompt in the project switcher has been changed
slightly. To get the previous one, set this option to 'brackets'.
*** 'project-try-vc' tries harder to find the responsible VCS.
When 'project-vc-extra-root-markers' is non-nil, and causes
subdirectory project to be detected which is not a VCS root, we now
additionally traverse the parent directories until a VCS root is found
(if any), so that the ignore rules for that repository are used, and
the file listing's performance is still optimized.
* Incompatible Lisp Changes in Emacs 30.1

View file

@ -567,6 +567,12 @@ See `project-vc-extra-root-markers' for the marker value format.")
(let* ((parent (file-name-directory (directory-file-name root))))
(setq root (vc-call-backend 'Git 'root parent))))
(when root
(when (not backend)
(let* ((project-vc-extra-root-markers nil)
;; Avoid submodules scan.
(enable-dir-local-variables nil)
(parent (project-try-vc root)))
(and parent (setq backend (nth 1 parent)))))
(setq project (list 'vc backend root))
;; FIXME: Cache for a shorter time.
(vc-file-setprop dir 'project-vc project)

View file

@ -137,6 +137,7 @@ When `project-ignores' includes a name matching project dir."
(project-vc-extra-root-markers '("files-x-tests.*"))
(project (project-current nil dir)))
(should-not (null project))
(should (nth 1 project))
(should (string-match-p "/test/lisp/\\'" (project-root project)))))
(ert-deftest project-vc-supports-project-in-different-dir ()