]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-dir-mark-file: Consistently don't allow marking a subdirectory
authorSean Whitton <spwhitton@spwhitton.name>
Sun, 6 Apr 2025 01:09:32 +0000 (09:09 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 8 Apr 2025 05:45:33 +0000 (07:45 +0200)
* lisp/vc/vc-dir.el (vc-dir-mark-file): Don't allow marking a
subdirectory if its parent is already marked.  This fixes an
inconsistency whereby if a subdirectory was already marked then
its parent could not be marked, but not vice-versa (bug #76769).

(cherry picked from commit a5f574429db1f820cc4d25bfb0e700aae050dc07)

lisp/vc/vc-dir.el

index 74a4d631e79b4a0d56ad081eadfa9031208a652b..35dbeaa707615a636d44794e054892b69872f851 100644 (file)
@@ -684,15 +684,15 @@ With prefix argument ARG, move that many lines."
          (file (ewoc-data crt))
         (isdir (vc-dir-fileinfo->directory file))
         ;; Forbid marking a directory containing marked files in its
-        ;; tree, or a file in a marked directory tree.
-        (conflict (if isdir
-                      (vc-dir-children-marked-p crt)
-                    (vc-dir-parent-marked-p crt))))
-    (when conflict
-      (error (if isdir
-                "File `%s' in this directory is already marked"
+        ;; tree, or a file or directory in a marked directory tree.
+         (child-conflict (and isdir (vc-dir-children-marked-p crt)))
+         (parent-conflict (vc-dir-parent-marked-p crt)))
+    (when (or child-conflict parent-conflict)
+      (error (if child-conflict
+                "Entry `%s' in this directory is already marked"
               "Parent directory `%s' is already marked")
-            (vc-dir-fileinfo->name conflict)))
+            (vc-dir-fileinfo->name (or child-conflict
+                                        parent-conflict))))
     (setf (vc-dir-fileinfo->marked file) t)
     (ewoc-invalidate vc-ewoc crt)
     (unless (or arg (mouse-event-p last-command-event))