diff options
| author | Dmitry Gutov | 2020-05-15 08:10:22 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2020-05-15 08:10:22 +0300 |
| commit | 779bc886f9bc2e3188bf2577c3df2ae662ca1b98 (patch) | |
| tree | 772a7f1b2282bba8df15142a49fcf261209a5343 | |
| parent | 065f6a1d8b5c7dc8f1bf758e22f2e9a7d17b47d4 (diff) | |
| download | emacs-779bc886f9bc2e3188bf2577c3df2ae662ca1b98.tar.gz emacs-779bc886f9bc2e3188bf2577c3df2ae662ca1b98.zip | |
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).
| -rw-r--r-- | lisp/progmodes/project.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ca8b5fa84e0..eeff809e2a3 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ;;; project.el --- Operations on the current project -*- lexical-binding: t; -*- | 1 | ;;; project.el --- Operations on the current project -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2015-2020 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2015-2020 Free Software Foundation, Inc. |
| 4 | ;; Version: 0.1 | 4 | ;; Version: 0.1.1 |
| 5 | ;; Package-Requires: ((emacs "26.3")) | 5 | ;; Package-Requires: ((emacs "26.3")) |
| 6 | 6 | ||
| 7 | ;; This is a GNU ELPA :core package. Avoid using functionality that | 7 | ;; This is a GNU ELPA :core package. Avoid using functionality that |
| @@ -274,8 +274,23 @@ backend implementation of `project-external-roots'.") | |||
| 274 | ('Git | 274 | ('Git |
| 275 | ;; Don't stop at submodule boundary. | 275 | ;; Don't stop at submodule boundary. |
| 276 | (or (vc-file-getprop dir 'project-git-root) | 276 | (or (vc-file-getprop dir 'project-git-root) |
| 277 | (vc-file-setprop dir 'project-git-root | 277 | (let* ((default-directory dir) |
| 278 | (vc-find-root dir ".git/")))) | 278 | (root (vc-root-dir))) |
| 279 | (vc-file-setprop | ||
| 280 | dir 'project-git-root | ||
| 281 | (cond | ||
| 282 | ((file-directory-p (expand-file-name ".git" root)) | ||
| 283 | root) | ||
| 284 | ((with-temp-buffer | ||
| 285 | (insert-file-contents ".git") | ||
| 286 | (goto-char (point-min)) | ||
| 287 | (looking-at "gitdir: [./]+/\.git/modules/")) | ||
| 288 | (let* ((parent (file-name-directory | ||
| 289 | (directory-file-name root))) | ||
| 290 | (default-directory parent)) | ||
| 291 | (vc-root-dir))) | ||
| 292 | (t root))) | ||
| 293 | ))) | ||
| 279 | ('nil nil) | 294 | ('nil nil) |
| 280 | (_ (ignore-errors (vc-call-backend backend 'root dir)))))) | 295 | (_ (ignore-errors (vc-call-backend backend 'root dir)))))) |
| 281 | (and root (cons 'vc root)))) | 296 | (and root (cons 'vc root)))) |