GNU bug report logs - #59257
29.0.50;vc-git-mode-line-string out of range

Previous Next

Package: emacs;

Reported by: Uwe Brauer <oub <at> mat.ucm.es>

Date: Mon, 14 Nov 2022 23:15:02 UTC

Severity: normal

Merged with 59011

Found in version 29.0.50

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 59257 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Uwe Brauer <oub <at> mat.ucm.es>, 59257 <at> debbugs.gnu.org
Subject: Re: bug#59257: 29.0.50;vc-git-mode-line-string out of range
Date: Mon, 14 Nov 2022 19:09:40 -0800
Uwe Brauer <oub <at> mat.ucm.es> writes:

> When opening a file that is under git version control I obtain the
> following error:
>
> Debugger entered--Lisp error: (args-out-of-range "main" 0 7)
>   vc-git-mode-line-string("/home/oub/1-Matlab-Git/matlab-test/testode.m")
>   apply(vc-git-mode-line-string "/home/oub/1-Matlab-Git/matlab-test/testode.m")
>   vc-call-backend(Git mode-line-string "/home/oub/1-Matlab-Git/matlab-test/testode.m")
>   vc-mode-line("/home/oub/1-Matlab-Git/matlab-test/testode.m" Git)
>   vc-after-save()
>   basic-save-buffer(t)
>   save-buffer(1)
>   funcall-interactively(save-buffer 1)
>   call-interactively(save-buffer nil nil)
>   command-execute(save-buffer)

It seems like `vc-git--symbolic-ref' returns nil when it shouldn't?

I think the attached patch will stop the backtrace from happening, but
it's more of a workaround:

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index a1ff03144b..ae3cada3d7 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -391,7 +391,7 @@ vc-git-mode-line-string
   "Return a string for `vc-mode-line' to put in the mode line for FILE."
   (let* ((rev (vc-working-revision file 'Git))
          (disp-rev (or (vc-git--symbolic-ref file)
-                       (and rev (substring rev 0 7))))
+                       (and rev (string-limit rev 7))))
          (def-ml (vc-default-mode-line-string 'Git file))
          (help-echo (get-text-property 0 'help-echo def-ml))
          (face   (get-text-property 0 'face def-ml)))




This bug report was last modified 151 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.