vc-dir-recompute-file-state: Return nil state for nonexistent file

* lisp/vc/vc-dir.el (vc-dir-recompute-file-state): Return nil
state for nonexistent file (bug#81191).
This commit is contained in:
Sean Whitton 2026-06-09 12:09:14 +01:00
parent 71ea4bbb6c
commit 466789b511

View file

@ -1270,16 +1270,19 @@ that file."
(defun vc-dir-recompute-file-state (fname def-dir)
"Compute state of FNAME known to live inside DEF-DIR."
(let* ((file-short (file-relative-name fname def-dir))
(_remove-me-when-CVS-works
(let ((fname-short (file-relative-name fname def-dir)))
(when (eq vc-dir-backend 'CVS)
;; FIXME: Warning: UGLY HACK. The CVS backend caches the state
;; info, this forces the backend to update it.
(vc-call-backend vc-dir-backend 'registered fname)))
(state (vc-call-backend vc-dir-backend 'state fname))
(extra (vc-call-backend vc-dir-backend
'status-fileinfo-extra fname)))
(list file-short state extra)))
(vc-call-backend vc-dir-backend 'registered fname))
;; Ensure we return a nil state if the file does not exist so that
;; it disappears from VC-Dir (bug#81191).
(if (file-exists-p fname)
(list fname-short
(vc-call-backend vc-dir-backend 'state fname)
(vc-call-backend vc-dir-backend
'status-fileinfo-extra fname))
(list fname-short nil nil))))
(defun vc-dir-find-child-files (dirname)
;; Give a DIRNAME string return the list of all child files shown in
@ -1339,6 +1342,7 @@ that file."
(ewoc-set-hf vc-ewoc
(vc-dir-headers vc-dir-backend ddir) ""))
(let* ((complete-state
;; Pass two truenames (bug#80803, bug#80967).
(vc-dir-recompute-file-state file
(file-truename ddir)))
(state (cadr complete-state)))