bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59257: 29.0.50;vc-git-mode-line-string out of range


From: Stefan Kangas
Subject: 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@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)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]