emacs-31 97e24e12d5b: Fix C-x v w a/A on the repository root

Sean Whitton <[email protected]> Mon, 27 Jul 2026 08:53:53 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 97e24e12d5b7174d5b22d8dcd61a7bb0effee916
Author: Sean Whitton <[email protected]>
Commit: Sean Whitton <[email protected]>

    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.
---
 lisp/vc/vc.el                     | 25 +++++++++++++------------
 test/lisp/vc/vc-tests/vc-tests.el | 14 +++++++-------
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 2e4aa014181..c33aae6ce4f 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -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")
diff --git a/test/lisp/vc/vc-tests/vc-tests.el b/test/lisp/vc/vc-tests/vc-tests.el
index 0e34e571a12..e75f20bce49 100644
--- a/test/lisp/vc/vc-tests/vc-tests.el
+++ b/test/lisp/vc/vc-tests/vc-tests.el
@@ -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