aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2026-02-27 12:08:27 +0000
committerSean Whitton2026-02-27 12:08:27 +0000
commit9bb9074d93504ac85ff518fd014fcb37cd27bbc9 (patch)
tree8b1c0c4c3a5b09cb7178a161212a7e3478e23ab4
parentf0dbe25d4c77b9a369badb79ec3e72b64c821e68 (diff)
downloademacs-9bb9074d93504ac85ff518fd014fcb37cd27bbc9.tar.gz
emacs-9bb9074d93504ac85ff518fd014fcb37cd27bbc9.zip
Fix renaming directories in VC repositories
* lisp/dired-aux.el (dired-rename-file): When determining whether to call vc-rename-file, use vc-responsible-backend instead of vc-backend when FILE is a directory. * lisp/vc/vc.el (vc-rename-file): Support renaming directories.
-rw-r--r--lisp/dired-aux.el4
-rw-r--r--lisp/vc/vc.el17
2 files changed, 14 insertions, 7 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 9d8476e3e75..026e19fb779 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2358,7 +2358,9 @@ unless OK-IF-ALREADY-EXISTS is non-nil."
2358 (dired-handle-overwrite newname) 2358 (dired-handle-overwrite newname)
2359 (dired-maybe-create-dirs (file-name-directory newname)) 2359 (dired-maybe-create-dirs (file-name-directory newname))
2360 (if (and dired-vc-rename-file 2360 (if (and dired-vc-rename-file
2361 (vc-backend file) 2361 (if file-is-dir-p
2362 (ignore-errors (vc-responsible-backend file))
2363 (vc-backend file))
2362 (ignore-errors (vc-responsible-backend newname))) 2364 (ignore-errors (vc-responsible-backend newname)))
2363 (vc-rename-file file newname) 2365 (vc-rename-file file newname)
2364 ;; error is caught in -create-files 2366 ;; error is caught in -create-files
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9d9366eed41..9654f2bb699 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -5032,18 +5032,23 @@ current buffer's file name if it's under version control."
5032 (cl-callf expand-file-name old) 5032 (cl-callf expand-file-name old)
5033 (cl-callf expand-file-name new) 5033 (cl-callf expand-file-name new)
5034 (let ((oldbuf (get-file-buffer old)) 5034 (let ((oldbuf (get-file-buffer old))
5035 (default-directory (file-name-directory old))) 5035 (default-directory (file-name-directory old))
5036 (dirp (file-directory-p old)))
5036 (when (and oldbuf (buffer-modified-p oldbuf)) 5037 (when (and oldbuf (buffer-modified-p oldbuf))
5037 (error "Please save files before moving them")) 5038 (error "Please save files before moving them"))
5038 (when (get-file-buffer new) 5039 (when (get-file-buffer new)
5039 (error "Already editing new file name")) 5040 (error "Already editing new file name"))
5040 (when (file-exists-p new) 5041 (when (file-exists-p new)
5041 (error "New file already exists")) 5042 (error "New file already exists"))
5042 (let ((state (vc-state old))) 5043 (unless dirp
5043 (unless (memq state '(up-to-date edited added)) 5044 (let ((state (vc-state old)))
5044 (error "Please %s files before moving them" 5045 (unless (memq state '(up-to-date edited added))
5045 (if (stringp state) "check in" "update")))) 5046 (error "Please %s files before moving them"
5046 (vc-call rename-file old new) 5047 (if (stringp state) "check in" "update")))))
5048 (vc-call-backend (if dirp
5049 (vc-responsible-backend old)
5050 (vc-backend old))
5051 'rename-file old new)
5047 (vc-file-clearprops old) 5052 (vc-file-clearprops old)
5048 (vc-file-clearprops new) 5053 (vc-file-clearprops new)
5049 ;; Move the actual file (unless the backend did it already) 5054 ;; Move the actual file (unless the backend did it already)