From 466789b511ab3a28b725f927967cff43cc745e9c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 9 Jun 2026 12:09:14 +0100 Subject: [PATCH] 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). --- lisp/vc/vc-dir.el | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index aa4bf7b2ec8..eb1982244a1 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -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 - (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))) + (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)) + ;; 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)))