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

From: Sean Whitton <[email-masked]>
Date: Thu, 27 Mar 2025 19:13:40 +0800

X-debbugs-cc: [email-masked], [email-masked]

A similar problem to #53626 crops up with C-x v L, too.

1. emacs -q
2. Visit a version controlled file.
3. C-x v L
4. Without switching buffer, C-x p p ~/some/other/repo RET o C-x v L
5. RET to toggle display of the log message.

Result, in the case of git, is "fatal: bad revision" because
default-directory is still the first VC repository's root.

This problem is caused by the let binding of default-directory
established by vc-print-root-log.  vc-setup-buffer wants to set
default-directory in the *vc-change-log* buffer to the new repository's
root, but ends up just adjusting the let binding's value.

The same thing probably occurs with C-x v D.

Could we reformulate the command definitions so that they didn't need to
bind default-directory?  Should vc-setup-buffer use the same
run-with-timer trick implemented in xref--ensure-default-directory?

CCing Stefan since this is a dynamic binding issue.

-- 
Sean Whitton