]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-dir-update: Update 'backend' VC properties
authorSean Whitton <spwhitton@spwhitton.name>
Sat, 28 Jun 2025 09:30:29 +0000 (10:30 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 20:07:35 +0000 (22:07 +0200)
* lisp/vc/vc-dir.el (vc-dir-update): Update 'backend' VC file
properties from ENTRIES.  This resolves some issues relating to
cache invalidation.
* lisp/vc/vc-hooks.el (vc-backend): Improve docstring.

(cherry picked from commit 6cd9574e20dccb15924dd42f0f481ba5b7367a42)

lisp/vc/vc-dir.el
lisp/vc/vc-hooks.el

index ae648deadee2f21cd99f152c01e4859f2c76492b..7ab119abc139997206163a698e3cddf3b21df136 100644 (file)
@@ -487,9 +487,11 @@ If BODY uses EVENT, it should be a variable,
           (vc-dir-fileinfo->name data)))))))
 
 (defun vc-dir-update (entries buffer &optional noinsert)
-  "Update BUFFER's ewoc from the list of ENTRIES.
-If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
-  ;; Add ENTRIES to the vc-dir buffer BUFFER.
+  "Update BUFFER's VC-Dir ewoc from ENTRIES.
+This has the effect of adding ENTRIES to the VC-Dir buffer BUFFER.
+If optional argument NOINSERT is non-nil, update ewoc nodes, but don't
+add elements of ENTRIES to the buffer that aren't already in the ewoc.
+Also update some VC file properties from ENTRIES."
   (with-current-buffer buffer
     ;; Insert the entries sorted by name into the ewoc.
     ;; We assume the ewoc is sorted too, which should be the
@@ -592,7 +594,11 @@ If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
                               (apply #'vc-dir-create-fileinfo entry))))))
       (when to-remove
        (let ((inhibit-read-only t))
-         (apply #'ewoc-delete vc-ewoc (nreverse to-remove)))))))
+         (apply #'ewoc-delete vc-ewoc (nreverse to-remove)))))
+    ;; Update VC file properties.
+    (pcase-dolist (`(,file ,state ,_extra) entries)
+      (vc-file-setprop file 'vc-backend
+                       (if (eq state 'unregistered) 'none vc-dir-backend)))))
 
 (defun vc-dir-busy ()
   (and (buffer-live-p vc-dir-process-buffer)
index 0b81b5d1866a7aca01c26c794f17b99745dd8e54..21f1df007df9d5f1c4e6d1d493308450df7f7164 100644 (file)
@@ -377,7 +377,10 @@ backend is tried first."
 
 (defun vc-backend (file-or-list)
   "Return the version control type of FILE-OR-LIST, nil if it's not registered.
-If the argument is a list, the files must all have the same back end."
+If the argument is a list, the files must all have the same back end.
+
+This function returns cached information.  To query the VCS regarding
+whether FILE-OR-LIST is registered or unregistered, use `vc-registered'."
   ;; `file' can be nil in several places (typically due to the use of
   ;; code like (vc-backend buffer-file-name)).
   (cond ((stringp file-or-list)