1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

vc-dir-update: Update 'backend' VC properties

* 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.
This commit is contained in:
Sean Whitton 2025-06-28 10:30:29 +01:00
parent b4d3ac1e04
commit 6cd9574e20
2 changed files with 14 additions and 5 deletions

View 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)

View 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)