Subject: Re: bug#77306: 31.0.50; C-x v L from *vc-change-log* buffer leaves wrong default-directory

From: Stefan Monnier <[email-masked]>
Date: Thu, 03 Apr 2025 14:25:14 -0400

> Could we reformulate the command definitions so that they didn't need to
> bind default-directory?

We could do something like the patch below, I guess.

        Stefan

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 2db2a017525..b0161270d4f 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3095,7 +3095,6 @@ vc-print-root-log
     (t
      (list (when (> vc-log-show-limit 0) vc-log-show-limit)))))
   (let* ((backend (vc-deduce-backend))
-	 (default-directory default-directory)
 	 (with-diff (and (eq limit 1) revision))
 	 (vc-log-short-style (unless with-diff vc-log-short-style))
 	 rootdir)
@@ -3105,12 +3104,14 @@ vc-print-root-log
       (setq backend (vc-responsible-backend rootdir))
       (unless backend
         (error "Directory is not version controlled")))
-    (setq default-directory rootdir)
-    (vc-print-log-internal backend (list rootdir) revision revision limit
-                           (when with-diff 'with-diff))
-    ;; We're looking at the root, so displaying " from <some-file>" in
-    ;; the mode line isn't helpful.
-    (setq vc-parent-buffer-name nil)))
+    (with-temp-buffer
+      (setq default-directory rootdir)
+      (vc-print-log-internal backend (list rootdir) revision revision limit
+                             (when with-diff 'with-diff))
+      ;; We're looking at the root, so displaying " from <some-file>" in
+      ;; the mode line isn't helpful.
+      ;; FIXME: In this eval'd in the appropriate buffer?
+      (setq vc-parent-buffer-name nil))))
 
 ;;;###autoload
 (defun vc-print-branch-log (branch)