1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-23 06:00:41 -08:00

project-try-vc: Fix the "sometimes wrong cache" issue

* lisp/progmodes/project.el (project-try-vc--search):
Extract from 'project-try-vc'.
(project-try-vc): Use it.
(project-try-vc--search): Call itself recursively directly, to
avoid creating invalid cache entry (bug#73801).

(cherry picked from commit 29b30eb49f)
This commit is contained in:
Dmitry Gutov 2024-10-28 05:53:16 +02:00
parent 8113b5c562
commit b4b0d5a853

View file

@ -543,10 +543,15 @@ project backend implementation of `project-external-roots'.")
See `project-vc-extra-root-markers' for the marker value format.")
(defun project-try-vc (dir)
;; FIXME: Learn to invalidate when the value of
;; `project-vc-merge-submodules' or `project-vc-extra-root-markers'
;; changes.
;; FIXME: Learn to invalidate when the value changes:
;; `project-vc-merge-submodules' or `project-vc-extra-root-markers'.
(or (vc-file-getprop dir 'project-vc)
;; FIXME: Cache for a shorter time.
(let ((res (project-try-vc--search dir)))
(and res (vc-file-setprop dir 'project-vc res))
res)))
(defun project-try-vc--search (dir)
(let* ((backend-markers
(delete
nil
@ -592,12 +597,10 @@ See `project-vc-extra-root-markers' for the marker value format.")
(let* ((project-vc-extra-root-markers nil)
;; Avoid submodules scan.
(enable-dir-local-variables nil)
(parent (project-try-vc root)))
(parent (project-try-vc--search 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)
project))))
project)))
(defun project--submodule-p (root)
;; XXX: We only support Git submodules for now.