From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#24725: 25.1.50; vc-region-history may exceed max line number of file in repository Date: Thu, 20 Oct 2016 13:22:10 +0900 Message-ID: <8737jrejkd.fsf@gmail.com> References: <87y41llol4.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1476937418 13955 195.159.176.226 (20 Oct 2016 04:23:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2016 04:23:38 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 24725@debbugs.gnu.org, tino.calancha@gmail.com To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 20 06:23:34 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx4sq-0000IU-8B for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 06:23:12 +0200 Original-Received: from localhost ([::1]:52318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx4ss-0001Wz-Fq for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 00:23:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx4sj-0001WZ-47 for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 00:23:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx4sg-000635-0J for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 00:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bx4sf-00062f-SG for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 00:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bx4sf-0004oU-K0 for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 00:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Oct 2016 04:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24725-submit@debbugs.gnu.org id=B24725.147693734518459 (code B ref 24725); Thu, 20 Oct 2016 04:23:01 +0000 Original-Received: (at 24725) by debbugs.gnu.org; 20 Oct 2016 04:22:25 +0000 Original-Received: from localhost ([127.0.0.1]:40205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx4s5-0004nf-J3 for submit@debbugs.gnu.org; Thu, 20 Oct 2016 00:22:25 -0400 Original-Received: from mail-pf0-f169.google.com ([209.85.192.169]:34389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx4s4-0004nT-V7 for 24725@debbugs.gnu.org; Thu, 20 Oct 2016 00:22:25 -0400 Original-Received: by mail-pf0-f169.google.com with SMTP id r16so28165044pfg.1 for <24725@debbugs.gnu.org>; Wed, 19 Oct 2016 21:22:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:cc:date:in-reply-to:message-id :user-agent:mime-version; bh=egAcAmCUBXR2p29pUsYWBibuUQ4St0LAVeT/hwdFQ+A=; b=ZtiQZJSycw+eWHkGVVQvz7shWZV2RRdhAJd9vuxwpfHAecitJ6glZgngjLBly5QuYL Jc+477KxyjYp1DT8ojjIfOG40HZ97e9sgY+YfgXKu5efT382C1z6ArKazEpnk8yJK2Ml 0laXeaHVpUkDovXnlRH+mg5kZqZSNDPRU/iMc382CA9AbFbwbOlz2h8s0czsksl6IXYQ YvLIHcyx98X8Er1jprwr2v7a2qfEUWvZeu1lsNDkxv/X8U6XcqE6FYD0UK6C0Y/M0cZy XaWPLf0tM8EWDnZ7PyuB4P01HegAu+8n8c7dNbeXW3hFxK22gtoD4hEyEqbTqiVt6k6L VzZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:cc:date:in-reply-to :message-id:user-agent:mime-version; bh=egAcAmCUBXR2p29pUsYWBibuUQ4St0LAVeT/hwdFQ+A=; b=QpA1cyxEGx+LOIs41VdJuevPUciYB6FxGsXbUzrxnmZyNCOqGkicSc1jSwcD/cuxAE gWwE4KoPp06Iu0Zq8VQYwWqiR8yrPXysXSXRiuCZGu2r+rdjH+WxSuQ0EehBwYOP5JBp uIRKKz5XMS70WTcvHmpe6jf58LJut7V9GwNTj2cgy5T2SCTwQDHuPFE/odjUIihWxk5O y/H+LnhHT9j1S51uoWNODRLeoVZMLuZpWcnB1jxim9hW3LENznUXPFKKzQ+CALnILURd hVtR2dngWM20TiqQtXMc5d/ZXJvywZu/WG1mmIN6n99jprmRn/Or0AO65dP3I++7mWAu BuXg== X-Gm-Message-State: AA6/9RnJues3LrLVH/qg32dJgfIvqkvvKeZNid9FGHvj3mpPGyNHfBgbh2gPlJBhrXvO+Q== X-Received: by 10.98.102.84 with SMTP id a81mr17417599pfc.176.1476937339012; Wed, 19 Oct 2016 21:22:19 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id e74sm66380189pfk.13.2016.10.19.21.22.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Oct 2016 21:22:18 -0700 (PDT) In-Reply-To: (Dmitry Gutov's message of "Thu, 20 Oct 2016 02:22:32 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:124703 Archived-At: Dmitry Gutov writes: > Hi! > > On 18.10.2016 17:27, Tino Calancha wrote: >> >> 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. > > With your patch, what will happen if the file does not end with a > newline (which can be some people's or tools' preference)? In that case my patch is wrong: it excludes the last line from the region. > Currently, in that case the above scenario works fine. Maybe we need a > different check, rather than substracting. > > Or try (line-number-at-pos (1- (point-max))) instead of (1- > (line-number-at-pos (point-max))). Thank you. Your suggestion handle both cases correctly. Following is the new patch: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From c9ce3a54f572549ea2027108694eb556b5cbe8f3 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Thu, 20 Oct 2016 12:22:51 +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#24725). --- 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..c6a9064 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 (line-number-at-pos (1- (point-max)))) + (setq lto (line-number-at-pos (1- (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-20 Repository revision: 8988327d548db7b69f30ea15496ccb0726fa4502