Fix C-x v w a/A on the repository root

With regard to vc--fileset-by-state, all the cond* clauses after
the '(atom next)' clause were essentially dead code.

With regard to vc-dir-status-files, when operating on the
repository root we would pass "./" to vc-dir-status-files, which
isn't a sensible value for 'default-directory'.

* lisp/vc/vc.el (vc-dir-status-files): Call expand-file-name on
DIRECTORY before using it.
(vc--fileset-by-state): Fix the control flow.
* test/lisp/vc/vc-tests/vc-tests.el
(vc-test--apply-to-other-working-tree): Pass the repository root
as the fileset instead of the five file names in order to test
vc--fileset-by-state's control flow.
This commit is contained in:
Sean Whitton 2026-07-27 13:52:52 +01:00
parent b65f8ef93d
commit 97e24e12d5
2 changed files with 20 additions and 19 deletions

View file

@ -5700,9 +5700,9 @@ yourself with a function like `vc-file-tree-walk'."
;; having to load `vc-dir' just to get access to this simple wrapper.
(let ((morep t) results)
(with-temp-buffer
(setq default-directory directory)
(setq default-directory (expand-file-name directory))
(vc-call-backend (or backend (vc-responsible-backend directory))
'dir-status-files directory files
'dir-status-files default-directory files
(lambda (entries &optional more-to-come)
(let (entry)
(while (setq entry (pop entries))
@ -6036,16 +6036,17 @@ non-ignored, non-up-to-date files within those directories."
(remaining (cadr fileset))
ret-val)
(while remaining
(cond* ((bind* (next (pop remaining))))
((atom next)
(push next (alist-get (vc-state next backend) ret-val)))
((bind* (file (car next))))
((file-directory-p file)
(setq remaining
(nconc (vc-dir-status-files file nil backend)
remaining)))
(t
(push file (alist-get (cadr next) ret-val)))))
(let* ((next (pop remaining))
(file (if (consp next) (car next) next)))
(if (file-directory-p file)
(setq remaining
(nconc (vc-dir-status-files file nil backend)
remaining))
(push file
(alist-get (if (consp next)
(cadr next)
(vc-state next backend))
ret-val)))))
ret-val))
(declare-function diff-kill-creations-deletions "diff-mode")

View file

@ -1010,13 +1010,13 @@ This checks also `vc-backend' and `vc-responsible-backend'."
(should (eq (vc-state "qux" backend) 'added))
(should (eq (vc-state "quux" backend) 'unregistered)))
(cl-flet ((go ()
(let ((default-directory first)
(vc-no-confirm-moving-changes t))
(vc--apply-to-other-working-tree
second second `(,backend
("foo" "bar" "baz" "qux" "quux"))
nil t))))
(cl-flet
((go ()
(let ((default-directory first)
(vc-no-confirm-moving-changes t))
(vc--apply-to-other-working-tree second second
`(,backend (,first))
nil t))))
(let ((default-directory second))
;; Set up a series of incompatibilities, one-by-one, and
;; try to move. In each case the problem should block the