emacs-devel
[Top][All Lists]
Advanced

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

Re: project.el: git submodules?


From: Dmitry Gutov
Subject: Re: project.el: git submodules?
Date: Fri, 15 May 2020 04:21:17 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 15.05.2020 00:38, Michael Welsh Duggan wrote:
I think you can just look for ^gitdir:.*/\.git/modules/
After all, I believe submodules all end up having their metadata within
.git/modules.

OK.

Here's a patch you can try:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ac56537b97..bc79e7591b 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -268,9 +268,24 @@ project-try-vc
           (pcase backend
             ('Git
              ;; Don't stop at submodule boundary.
-             (or (vc-file-getprop dir 'project-git-root)
-                 (vc-file-setprop dir 'project-git-root
-                                  (vc-find-root dir ".git/"))))
+             (or (vc-file-getprop dir 'project-vc-root)
+                 (let* ((default-directory dir)
+                        (root (vc-root-dir)))
+                   (vc-file-setprop
+                    dir 'project-vc-root
+                    (cond
+                     ((file-directory-p ".git")
+                      root)
+                     ((with-temp-buffer
+                        (insert-file-contents ".git")
+                        (goto-char (point-min))
+                        (looking-at "gitdir:[./]+/\.git/modules/"))
+                      (let* ((parent (file-name-directory
+                                      (directory-file-name root)))
+                             (default-directory parent))
+                        (vc-root-dir)))
+                     (t root)))
+                   )))
             ('nil nil)
             (_ (ignore-errors (vc-call-backend backend 'root dir))))))
     (and root (cons 'vc root))))



reply via email to

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