1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

vc-dir-resynch-file: Be more defensive about default-directory

* lisp/vc/vc-dir.el (vc-dir-resynch-file): Use both
expand-file-name and buffer-local-toplevel-value on
default-directory before using the value.
This commit is contained in:
Sean Whitton 2025-10-08 12:38:37 +01:00
parent 43cbdfb698
commit fb58ccfdc4
2 changed files with 18 additions and 5 deletions

View file

@ -1240,13 +1240,21 @@ that file."
(set-buffer status-buf)
(if (not (derived-mode-p 'vc-dir-mode))
(push status-buf drop)
(let ((ddir default-directory))
(let ((ddir (expand-file-name
;; The actual contents of this VC-Dir buffer,
;; which is what we care about here, is always
;; relative to the toplevel value.
;; If we invoked the current command from
;; STATUS-BUF then it might have shadowed
;; `default-directory' in order to do its work,
;; but that's irrelevant to us here.
(buffer-local-toplevel-value 'default-directory))))
(when (string-prefix-p ddir file)
(if (file-directory-p file)
(progn
(vc-dir-resync-directory-files file)
(ewoc-set-hf vc-ewoc
(vc-dir-headers vc-dir-backend default-directory) ""))
(vc-dir-headers vc-dir-backend ddir) ""))
(let* ((complete-state (vc-dir-recompute-file-state file ddir))
(state (cadr complete-state)))
(vc-dir-update

View file

@ -26,6 +26,11 @@
;; This is the preloaded portion of VC. It takes care of VC-related
;; activities that are done when you visit a file, so that vc.el itself
;; is loaded only when you use a VC command. See commentary of vc.el.
;;
;; The noninteractive hooks into the rest of Emacs are:
;; - `vc-refresh-state' in `find-file-hook'
;; - `vc-kill-buffer-hook' in `kill-buffer-hook'
;; - `vc-after-save' which is called by `basic-save-buffer'.
;;; Code:
@ -916,9 +921,9 @@ In the latter case, VC mode is deactivated for this buffer."
(not (equal buffer-file-name truename))
(vc-backend truename))))
(cond ((not link-type) nil) ;Nothing to do.
((eq vc-follow-symlinks nil)
(message
"Warning: symbolic link to %s-controlled source file" link-type))
((not vc-follow-symlinks)
(message "Warning: symbolic link to %s-controlled source file"
link-type))
((or (not (eq vc-follow-symlinks 'ask))
;; Assume we cannot ask, default to yes.
noninteractive