Subject: bug#59962: 29.0.60; vc commands fail in diff-mode

From: Sven Joachim <[email-masked]>
Date: Sun, 11 Dec 2022 13:25:11 +0100

As a distribution maintainer, I find myself working with
version-controlled patches which Emacs visits in diff-mode.
Unfortunately, there is a bad interaction between diff-mode and vc,
which makes all vc commands fail.  This is what I got on C-x v l:

,----
| Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
|   file-truename(nil)
|   find-buffer-visiting(nil)
|   vc-buffer-sync-fileset((Git (nil nil nil nil) nil nil patch) t)
|   vc-diff(nil t)
|   funcall-interactively(vc-diff nil t)
|   call-interactively(vc-diff nil nil)
|   command-execute(vc-diff)
`----

In GNU Emacs 29.0.60 (build 7, x86_64-pc-linux-gnu, GTK+ Version
 2.24.33, cairo version 1.16.0) of 2022-12-11 built on turtle
Repository revision: 9f7e5584a4ff3c61a90301f70366a829c2c0ac04
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --build x86_64-linux-gnu --host x86_64-linux-gnu
 --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var --infodir=/usr/share/info/emacs-snapshot
 --mandir=/usr/share/man --with-mailutils
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/29.0.60/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.0.60/site-lisp:/usr/share/emacs/site-lisp
 --without-wide-int --without-modules --disable-silent-rules
 --without-compress-install --with-x=yes --with-x-toolkit=gtk2
 --without-gconf --without-gsettings build_alias=x86_64-linux-gnu
 host_alias=x86_64-linux-gnu 'CFLAGS=-g -O2
 -fdebug-prefix-map=/usr/local/src/emacs=. -fstack-protector-strong
 -Wformat -Werror=format-security' 'LDFLAGS=-Wl,-z,relro
 -Wl,--as-needed' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2 -DDEBIAN
 -DSITELOAD_PURESIZE_EXTRA=5000 -DGLIB_DISABLE_DEPRECATION_WARNINGS''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG JSON LCMS2
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11
XDBE XIM XINPUT2 XPM GTK2 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date subr-x mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils display-line-numbers
cl-extra help-fns radix-tree cl-print byte-opt gv bytecomp byte-compile
debug backtrace help-mode find-func vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs log-view pcvs-util vc cus-start cus-load smerge-mode diff
vc-git vc-dispatcher diff-mode easy-mmode dired-aux cl-loaddefs cl-lib
dired dired-loaddefs rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting font-render-setting cairo move-toolbar gtk x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 73162 8220)
 (symbols 48 8827 0)
 (strings 32 25552 1356)
 (string-bytes 1 703829)
 (vectors 16 15405)
 (vector-slots 8 205042 14002)
 (floats 8 34 35)
 (intervals 56 755 0)
 (buffers 976 15))