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 17:09:07 +0900 Message-ID: <87r37bcuho.fsf@gmail.com> References: <87y41llol4.fsf@gmail.com> <8737jrejkd.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1476951022 4391 195.159.176.226 (20 Oct 2016 08:10:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Oct 2016 08:10:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 24725@debbugs.gnu.org, Dmitry Gutov , Tino Calancha To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 20 10:10:17 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 1bx8QZ-0000GS-9Y for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 10:10:15 +0200 Original-Received: from localhost ([::1]:53094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx8Qb-00067C-7A for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Oct 2016 04:10:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx8QQ-00062W-VN for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 04:10:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx8QM-0003LH-PG for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 04:10:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bx8QM-0003Ki-Lh for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 04:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bx8QM-0001v7-0h for bug-gnu-emacs@gnu.org; Thu, 20 Oct 2016 04:10:02 -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 08:10: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.14769509587315 (code B ref 24725); Thu, 20 Oct 2016 08:10:01 +0000 Original-Received: (at 24725) by debbugs.gnu.org; 20 Oct 2016 08:09:18 +0000 Original-Received: from localhost ([127.0.0.1]:40313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx8Pe-0001tv-0C for submit@debbugs.gnu.org; Thu, 20 Oct 2016 04:09:18 -0400 Original-Received: from mail-pf0-f179.google.com ([209.85.192.179]:35107) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bx8Pc-0001tc-B5 for 24725@debbugs.gnu.org; Thu, 20 Oct 2016 04:09:16 -0400 Original-Received: by mail-pf0-f179.google.com with SMTP id s8so31960206pfj.2 for <24725@debbugs.gnu.org>; Thu, 20 Oct 2016 01:09:16 -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=sMPIac8kmOBuv9yXwZU+ktn+EIwH4+wiSIC58HedpiY=; b=puINKYhc2jNqsfwdZ2DroODk9cbRNVLah2E32NysOmW4Ra5A3sJXSnjtRbmPniRPJK UFFZig5Ujhtow6cQUSOWOakeup8t4K9wq1llY2lN/93Az9uNnukpOyA4FQF/Vsk8IdZB aQHwoCySL27EdrFYUyYx/zSNTf4WHPNYO2+Rc2K9A/UbvHC2iAFb3pGoCw8SwapfGuLy dbGa/XJX8Mb6iLQmNBxd/ZqCGgYY6uMNsqu+DAyHnNNHVP+7UesbOPbX+e2i3/f//5mv YLmI+bcQ+kkn/iKhdi5s8CKos0JfV5juXnI5F/vvoSMYLwxY8yDjNg9Ml9njt7JMT8wk 8t9A== 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=sMPIac8kmOBuv9yXwZU+ktn+EIwH4+wiSIC58HedpiY=; b=EXb50hnxK22sL/ky2163B4xSeXy67pe/EQvRCLBhVjVUT88S2DM5HVqoQgsyTYKOgk QO/uACjTd+ial/Q0ZPnqV9zuJHImqk6T13elmXzidP0kPuJtzSuMK813j+Jta9b9u4Ui 8f6HSelv0ysTbBs/kUWzX0YqNH+tUehAQPzkMNXovef2RHJL8Kc+Itx17YZhfPcitvqz Jeej0hZ63CvvVEnx37Og4RxkjhICnpMa0QzrBK7Slv5f6sEC6pkfYxg/0fMS9MJOWqMu ikQcaNFJIEuKEA6kghN+jtH/p2n/U2WkV4AICevfjBMHH2D9Vkw9e4PalFYf71U2sGwA T2TQ== X-Gm-Message-State: AA6/9RlPjzrk1sAcclFKV9KHI29DQ4Y1PNsLbN3ATA7yNY/ngswap/tVVZJ92KQXjlJzdQ== X-Received: by 10.98.129.130 with SMTP id t124mr19024605pfd.5.1476950950836; Thu, 20 Oct 2016 01:09:10 -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 m188sm69256570pfc.40.2016.10.20.01.09.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Oct 2016 01:09:10 -0700 (PDT) In-Reply-To: (Andreas Schwab's message of "Thu, 20 Oct 2016 09:27:22 +0200") 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:124718 Archived-At: Andreas Schwab writes: > On Okt 20 2016, Tino Calancha wrote: > >> 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))))) > > 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? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From b05b6d12171ea270f6b392c8af7f4415414960e5 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Thu, 20 Oct 2016 17:00:04 +0900 Subject: [PATCH] vc-region-history: Search just on lines within the region * lisp/vc/vc.el (vc-region-history): If region ends in the beginning of a line, then exclude that line from the search (Bug#24725). --- lisp/vc/vc.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index af875e8..0d8e308 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2393,7 +2393,11 @@ vc-region-history "Show the history of the region FROM..TO." (interactive "r") (let* ((lfrom (line-number-at-pos from)) - (lto (line-number-at-pos to)) + (lto (save-excursion + (goto-char to) + (if (bolp) + (1- (line-number-at-pos to)) + (line-number-at-pos to)))) (file buffer-file-name) (backend (vc-backend file)) (buf (get-buffer-create "*VC-history*"))) -- 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