[Top][All Lists]

[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: Thu, 14 May 2020 22:29:23 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 14.05.2020 20:57, Stefan Monnier wrote:
I even have a patch, but here's another thought: wouldn't this mistakenly
punish people who keep their $HOME as a Git repository to sync
between machines?
Depends if the Git worktrees within their $HOME use the same repository
as the one used for $HOME.
Not 'git worktrees' (to be clear), just random other work directories, for
work/hobby/etc projects.

Yes, I make "work trees" in a generic sense not just in the `git worktree` 

Yes, a user option (inrended for dir-locals) is likely in order, but users
such as described above would have to set it in _all_ of their
work directories.

Not if the repository they use for $HOME is different than the one they
use for ~/work, ~/my/hobby/, ...

Then they'll only have to set it in ~/.dir-locals.el? Is that what you mean?

Here's the patch I made according to your description:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ac56537b97..bf737e821a 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -266,11 +266,18 @@ project-try-vc
   (let* ((backend (ignore-errors (vc-responsible-backend dir)))
           (pcase backend
-            ('Git
+            (`(or ,'Git ,'Hg)
              ;; 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))
+                        (parent (file-name-directory
+                                 (directory-file-name root))))
+                   (vc-file-setprop dir 'project-vc-root
+                                    (or
+                                     (let ((default-directory parent))
+                                       (vc-root-dir))
+                                     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]