From c75095567fea9b72fa9275d3bebbb3ce8a1a15d2 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 6 Apr 2025 11:09:22 +0800 Subject: [PATCH] Fix dired-vc-next-action generating inconsistent marks * lisp/vc/vc-dir.el (vc-dir-mark-files): Document that directories passed to this function must have trailing slashes. Don't mark both a directory and also items under it (bug#76769). * lisp/dired-aux.el (dired-vc-next-action): Update docstring. (cherry picked from commit c0b1b54d734a45698da9df0841700c4c15785b11) --- lisp/dired-aux.el | 12 ++++++------ lisp/vc/vc-dir.el | 12 +++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index aeed9b6b410..8d80625c5d0 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -3930,12 +3930,12 @@ If only regular files are in the fileset, call `vc-next-action' with the same value of the VERBOSE argument (interactively, the prefix argument). -If one or more directories are in the fileset, start `vc-dir' in the root -directory of the repository that includes the current directory, with -the same files/directories marked in the VC-Directory buffer that were -marked in the original Dired buffer. If the current directory doesn't -belong to a VCS repository, prompt for a repository directory. In this -case, the VERBOSE argument is ignored." +If one or more directories are in the fileset, start `vc-dir' in the +root directory of the repository that includes the current directory, +with all directories in the fileset marked in the VC-Directory buffer +that were marked in the original Dired buffer. If the current directory +doesn't belong to a VCS repository, prompt for a repository directory. +In this case, the VERBOSE argument is ignored." (interactive "P" dired-mode) (let* ((marked-files (dired-get-marked-files nil nil nil nil t)) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 35dbeaa7076..d8653c186cb 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -774,7 +774,17 @@ If UNMARK (interactively, the prefix), unmark instead." (defun vc-dir-mark-files (mark-files) "Mark files specified by file names in the argument MARK-FILES. -MARK-FILES should be a list of absolute filenames." +MARK-FILES should be a list of absolute filenames. +Directories must have trailing slashes." + ;; Filter out subitems that would be implicitly marked. + (setq mark-files (sort mark-files)) + (let ((next mark-files)) + (while next + (when (string-suffix-p "/" (car next)) + (while (string-prefix-p (car next) (cadr next)) + (rplacd next (cddr next)))) + (setq next (cdr next)))) + (ewoc-map (lambda (filearg) (when (member (expand-file-name (vc-dir-fileinfo->name filearg)) -- 2.39.5