]> git.eshelyaron.com Git - emacs.git/commitdiff
(project-try-vc): When found non-VC project root, still search for the backend
authorDmitry Gutov <dmitry@gutov.dev>
Wed, 6 Sep 2023 20:30:27 +0000 (23:30 +0300)
committerDmitry Gutov <dmitry@gutov.dev>
Wed, 6 Sep 2023 20:30:42 +0000 (23:30 +0300)
* 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).

etc/NEWS
lisp/progmodes/project.el
test/lisp/progmodes/project-tests.el

index a68e67e0694bf4208800753910637eb07e84a191..60c3e4265ea1ea8ef30bf43d5d70deb8908539ba 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
+
 \f
 * Incompatible Lisp Changes in Emacs 30.1
 
index 29a81c7e151f8c7109aa73ddca19a2c6bb360753..e17ca7c1d5b7ad93e2f21b94b5d51ecbc2e2b4d6 100644 (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)
index 5a206b67db1952d893d632c1ac4757ddfd00507f..d335864ca2e88dbbd6a758d8b1a1a7b6da293bc7 100644 (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 ()