GNU bug report logs - #24725
25.1.50; vc-region-history may exceed max line number of file in repository

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Tue, 18 Oct 2016 14:28:01 UTC

Severity: normal

Tags: patch

Found in version 25.1.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#24725: closed (25.1.50; vc-region-history may exceed max line
 number of file in repository)
Date: Thu, 20 Oct 2016 10:46:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 20 Oct 2016 19:44:54 +0900
with message-id <878ttjmh95.fsf <at> gmail.com>
and subject line Re: bug#24725: 25.1.50; vc-region-history may exceed max line number of file in repository
has caused the debbugs.gnu.org bug report #24725,
regarding 25.1.50; vc-region-history may exceed max line number of file in repository
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
24725: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24725
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50;
 vc-region-history may exceed max line number of file in repository
Date: Tue, 18 Oct 2016 23:27:19 +0900
emacs -Q lisp/vc/vc.el
C-x h
M-x vc-region-history RET
fatal: file vc.el has only 2921 lines
;; vc.el has 2922 lines but Git ignores the last empty line.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 12a6fc588fe60ebf98443a0fd068fe77d63bd17e Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Tue, 18 Oct 2016 23:20:07 +0900
Subject: [PATCH] vc-region-history: Do not exceed the file maximum line number

The last empty line in a file is not part of the Git repository.
* lisp/vc/vc.el (vc-region-history): Exclude the last empty line
from the region (Bug#24724).
---
 lisp/vc/vc-git.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 9eac5b2..762f6af 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1016,6 +1016,8 @@ vc-git-region-history
   ;; FIXME: Maybe this should be done in vc.el (i.e. for all backends), but
   ;; since Git is the only backend to support this operation so far, it's hard
   ;; to tell.
+  (when (> lto (1- (line-number-at-pos (point-max))))
+    (setq lto (1- (line-number-at-pos (point-max)))))
   (with-temp-buffer
     (vc-call-backend 'git 'diff file "HEAD" nil (current-buffer))
     (goto-char (point-min))
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1)
 of 2016-10-13 built on calancha-pc
Repository revision: baa8ba4ed471d7fe4bb07c80a9dd16c4712525b4



[Message part 3 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: 24725-done <at> debbugs.gnu.org
Cc: Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#24725: 25.1.50;
 vc-region-history may exceed max line number of file in repository
Date: Thu, 20 Oct 2016 19:44:54 +0900
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 20.10.2016 11:09, Tino Calancha wrote:
>
>>> Shouldn't that be fixed in the caller, and lto always be decremented if
>>> the regions ends at bol?
>> I think you are right.  Otherwise we are including a line out of the
>> region, i.e., in interactive calls we also search in the history for
>> a line out of the highlighted region.
>> How about following new patch?
>
> LGTM, please install.
>
> Although I was thinking of simplifying it to just:
>
> (line-number-at-pos (1- to))
>
> That can only bite us if TO is at bob, which would be very unusual.
Good.  It sounds more simple.
Pushed that simple fix to emacs-25 branch as commit 3877c911


This bug report was last modified 8 years and 212 days ago.

Previous Next


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