From a5f574429db1f820cc4d25bfb0e700aae050dc07 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 6 Apr 2025 09:09:32 +0800 Subject: [PATCH] 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). --- lisp/vc/vc-dir.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index fd3fc10822d..4f497eed8a1 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -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))