vc-dir-mark-file: Consistently don't allow marking a subdirectory

* 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).
This commit is contained in:
Sean Whitton 2025-04-06 09:09:32 +08:00
parent c418e454b3
commit a5f574429d

View 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))