Subject: bug#65763: Error opening a file from a Git working directory if Git is not installed

From: Paul Pogonyshev <[email-masked]>
Date: Sun, 10 Sep 2023 19:36:47 +0200

-       ((setq backend (with-demoted-errors "VC refresh error: %S"
-                        (vc-backend buffer-file-name)))
+       ((setq backend (let (debug-on-error)
+                        (with-demoted-errors "VC refresh error: %S"
+                          (vc-backend buffer-file-name))))

>From my experience, you should always comment such things. Or add an
automated test ensuring it. Or even better, do both. It is extremely
non-obvious why this is needed at all and someone can easily undo your
changes a few years later.

Paul

On Sun, 10 Sept 2023 at 15:40, Eli Zaretskii <[email-masked]> wrote:

> > Date: Sun, 10 Sep 2023 16:21:00 +0300
> > Cc: [email-masked], [email-masked]
> > From: Dmitry Gutov <[email-masked]>
> >
> > On 10/09/2023 09:26, Eli Zaretskii wrote:
> > > diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
> > > index a4de0a6..0715236 100644
> > > --- a/lisp/vc/vc-hooks.el
> > > +++ b/lisp/vc/vc-hooks.el
> > > @@ -799,7 +799,7 @@ vc-refresh-state
> > >       (add-hook 'vc-mode-line-hook #'vc-mode-line nil t)
> > >       (let (backend)
> > >         (cond
> > > -       ((setq backend (with-demoted-errors "VC refresh error: %S"
> > > +       ((setq backend (ignore-errors
> > >                           (vc-backend buffer-file-name)))
> > >           ;; Let the backend setup any buffer-local things he needs.
> > >           (vc-call-backend backend 'find-file-hook)
> >
> > This seems to work better:
>
> That'd be fine by me, but I'd still want to understand why
> ignore-errors didn't work.
>
> Thanks.
>