emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 62229fb2d11: (project-try-vc): When found non-VC project root, st


From: Dmitry Gutov
Subject: master 62229fb2d11: (project-try-vc): When found non-VC project root, still search for the backend
Date: Wed, 6 Sep 2023 16:37:48 -0400 (EDT)

branch: master
commit 62229fb2d11b34d46516d1b141e6af97677a74a7
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    (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).
---
 etc/NEWS                             | 7 +++++++
 lisp/progmodes/project.el            | 6 ++++++
 test/lisp/progmodes/project-tests.el | 1 +
 3 files changed, 14 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index a68e67e0694..60c3e4265ea 100644
--- 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.
+
 
 * Incompatible Lisp Changes in Emacs 30.1
 
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 29a81c7e151..e17ca7c1d5b 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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)
diff --git a/test/lisp/progmodes/project-tests.el 
b/test/lisp/progmodes/project-tests.el
index 5a206b67db1..d335864ca2e 100644
--- a/test/lisp/progmodes/project-tests.el
+++ b/test/lisp/progmodes/project-tests.el
@@ -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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]