emacs-diffs
[Top][All Lists]
Advanced

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

master 779bc88: Improve detection of Git submodules


From: Dmitry Gutov
Subject: master 779bc88: Improve detection of Git submodules
Date: Fri, 15 May 2020 01:10:30 -0400 (EDT)

branch: master
commit 779bc886f9bc2e3188bf2577c3df2ae662ca1b98
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Improve detection of Git submodules
    
    * lisp/progmodes/project.el (project-try-vc):
    Improve detection of Git submodules
    (https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg02008.html).
---
 lisp/progmodes/project.el | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ca8b5fa..eeff809 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1,7 +1,7 @@
 ;;; project.el --- Operations on the current project  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
-;; Version: 0.1
+;; Version: 0.1.1
 ;; Package-Requires: ((emacs "26.3"))
 
 ;; This is a GNU ELPA :core package.  Avoid using functionality that
@@ -274,8 +274,23 @@ backend implementation of `project-external-roots'.")
             ('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/"))))
+                 (let* ((default-directory dir)
+                        (root (vc-root-dir)))
+                   (vc-file-setprop
+                    dir 'project-git-root
+                    (cond
+                     ((file-directory-p (expand-file-name ".git" root))
+                      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]