diff options
| author | Sean Whitton | 2025-10-08 12:38:37 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-10-08 12:38:37 +0100 |
| commit | fb58ccfdc4ad7c4f0140b0b1a3cf27bcfe387b69 (patch) | |
| tree | fb957503b788a287b7445f89b291028b63ca16c2 | |
| parent | 43cbdfb69846e0ab4552f74bab372a38915db66d (diff) | |
| download | emacs-fb58ccfdc4ad7c4f0140b0b1a3cf27bcfe387b69.tar.gz emacs-fb58ccfdc4ad7c4f0140b0b1a3cf27bcfe387b69.zip | |
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.
| -rw-r--r-- | lisp/vc/vc-dir.el | 12 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 11 |
2 files changed, 18 insertions, 5 deletions
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 18848577052..f6f5714519d 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el | |||
| @@ -1240,13 +1240,21 @@ that file." | |||
| 1240 | (set-buffer status-buf) | 1240 | (set-buffer status-buf) |
| 1241 | (if (not (derived-mode-p 'vc-dir-mode)) | 1241 | (if (not (derived-mode-p 'vc-dir-mode)) |
| 1242 | (push status-buf drop) | 1242 | (push status-buf drop) |
| 1243 | (let ((ddir default-directory)) | 1243 | (let ((ddir (expand-file-name |
| 1244 | ;; The actual contents of this VC-Dir buffer, | ||
| 1245 | ;; which is what we care about here, is always | ||
| 1246 | ;; relative to the toplevel value. | ||
| 1247 | ;; If we invoked the current command from | ||
| 1248 | ;; STATUS-BUF then it might have shadowed | ||
| 1249 | ;; `default-directory' in order to do its work, | ||
| 1250 | ;; but that's irrelevant to us here. | ||
| 1251 | (buffer-local-toplevel-value 'default-directory)))) | ||
| 1244 | (when (string-prefix-p ddir file) | 1252 | (when (string-prefix-p ddir file) |
| 1245 | (if (file-directory-p file) | 1253 | (if (file-directory-p file) |
| 1246 | (progn | 1254 | (progn |
| 1247 | (vc-dir-resync-directory-files file) | 1255 | (vc-dir-resync-directory-files file) |
| 1248 | (ewoc-set-hf vc-ewoc | 1256 | (ewoc-set-hf vc-ewoc |
| 1249 | (vc-dir-headers vc-dir-backend default-directory) "")) | 1257 | (vc-dir-headers vc-dir-backend ddir) "")) |
| 1250 | (let* ((complete-state (vc-dir-recompute-file-state file ddir)) | 1258 | (let* ((complete-state (vc-dir-recompute-file-state file ddir)) |
| 1251 | (state (cadr complete-state))) | 1259 | (state (cadr complete-state))) |
| 1252 | (vc-dir-update | 1260 | (vc-dir-update |
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 6b6d01bc04c..e03313b5730 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el | |||
| @@ -26,6 +26,11 @@ | |||
| 26 | ;; This is the preloaded portion of VC. It takes care of VC-related | 26 | ;; This is the preloaded portion of VC. It takes care of VC-related |
| 27 | ;; activities that are done when you visit a file, so that vc.el itself | 27 | ;; activities that are done when you visit a file, so that vc.el itself |
| 28 | ;; is loaded only when you use a VC command. See commentary of vc.el. | 28 | ;; is loaded only when you use a VC command. See commentary of vc.el. |
| 29 | ;; | ||
| 30 | ;; The noninteractive hooks into the rest of Emacs are: | ||
| 31 | ;; - `vc-refresh-state' in `find-file-hook' | ||
| 32 | ;; - `vc-kill-buffer-hook' in `kill-buffer-hook' | ||
| 33 | ;; - `vc-after-save' which is called by `basic-save-buffer'. | ||
| 29 | 34 | ||
| 30 | ;;; Code: | 35 | ;;; Code: |
| 31 | 36 | ||
| @@ -916,9 +921,9 @@ In the latter case, VC mode is deactivated for this buffer." | |||
| 916 | (not (equal buffer-file-name truename)) | 921 | (not (equal buffer-file-name truename)) |
| 917 | (vc-backend truename)))) | 922 | (vc-backend truename)))) |
| 918 | (cond ((not link-type) nil) ;Nothing to do. | 923 | (cond ((not link-type) nil) ;Nothing to do. |
| 919 | ((eq vc-follow-symlinks nil) | 924 | ((not vc-follow-symlinks) |
| 920 | (message | 925 | (message "Warning: symbolic link to %s-controlled source file" |
| 921 | "Warning: symbolic link to %s-controlled source file" link-type)) | 926 | link-type)) |
| 922 | ((or (not (eq vc-follow-symlinks 'ask)) | 927 | ((or (not (eq vc-follow-symlinks 'ask)) |
| 923 | ;; Assume we cannot ask, default to yes. | 928 | ;; Assume we cannot ask, default to yes. |
| 924 | noninteractive | 929 | noninteractive |