]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix dired-vc-next-action generating inconsistent marks
authorSean Whitton <spwhitton@spwhitton.name>
Sun, 6 Apr 2025 03:09:22 +0000 (11:09 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 8 Apr 2025 05:45:35 +0000 (07:45 +0200)
* 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
lisp/vc/vc-dir.el

index aeed9b6b410c26cfbd585b2de2e103a00b6958e3..8d80625c5d0c25053b2c281e0fcceea32db635e8 100644 (file)
@@ -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))
index 35dbeaa707615a636d44794e054892b69872f851..d8653c186cb8fe9a96c513059a71023b612155c8 100644 (file)
@@ -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))