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#25410: 26.0.50; Refine an unified diff hunk only if adds lines Date: Tue, 10 Jan 2017 19:08:20 +0900 Message-ID: <8737grz0q3.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484042967 9134 195.159.176.226 (10 Jan 2017 10:09:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Jan 2017 10:09:27 +0000 (UTC) To: 25410@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 10 11:09:19 2017 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 1cQtMd-0000ge-K4 for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 11:09:11 +0100 Original-Received: from localhost ([::1]:46091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQtMh-0005Nw-RH for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 05:09:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQtMY-0005Ni-Ge for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:09:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQtMU-00006L-H7 for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:09:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQtMU-00006H-DQ for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cQtMU-0002ry-53 for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Jan 2017 10:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148404292210999 (code B ref -1); Tue, 10 Jan 2017 10:09:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Jan 2017 10:08:42 +0000 Original-Received: from localhost ([127.0.0.1]:48399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQtMA-0002rL-Fl for submit@debbugs.gnu.org; Tue, 10 Jan 2017 05:08:42 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQtM8-0002r4-Ok for submit@debbugs.gnu.org; Tue, 10 Jan 2017 05:08:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQtM2-0008Li-GW for submit@debbugs.gnu.org; Tue, 10 Jan 2017 05:08:35 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQtM2-0008Le-Da for submit@debbugs.gnu.org; Tue, 10 Jan 2017 05:08:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQtM1-0005HY-3w for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:08:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQtLw-0008Jz-0P for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:08:32 -0500 Original-Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQtLv-0008Jn-Qx for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 05:08:27 -0500 Original-Received: by mail-pf0-x244.google.com with SMTP id f144so9369328pfa.2 for ; Tue, 10 Jan 2017 02:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=wIegiNcfYhA52ufT8icyhjlOT9x22YzoFEqW7Ol1pic=; b=Cz45GMClZcYcPznWBQ4oCPPscmlyz/6WWJv2oGPsHCJ63QeiD10FaMjYpj0cLfWr9L eCoJNxeHjNa79GVDNvnqiZTNTqS1hZIVc+UuTVuaAclNWplOXKiQTFBVMvif+2rtnVwQ adevvWonPd89Z7WfIGFjsx3HhY/12JCy9JeqYWDOvPQNa1lkJHg+qXH+iuCYu0z+MN5b /4LJsslJ2kEUcPhYsPlq7Mj/HmuVJcX2Uqxmvvt/RUleWs7MA9YHFNk8PF079UQ7X7au fVKHrDwu40tbJUcYkXwJbNFPqHbw64hQAfkcLigQADZvD31ekB4WwfAQ2sm/X5xHAB0t DmOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=wIegiNcfYhA52ufT8icyhjlOT9x22YzoFEqW7Ol1pic=; b=A/kh1XL0R+bnzQ0QMOkJSc3wAFROmsVA+Uc1tQneFN1RDX+drJhBLEdn1ZkdJHVRoc m2PAtcd050yySsloHT4flRiDLxKEXVaXd1lTqdt0+6FiGz/1PfL2FqE0rtjUqXUhLmht aB0omazRfsduMwlzxvop850cDm47rfSuLPfSlZUhSxzYb5OgPv/0OMyn4q15Dwi/TDlB Vr8/p7Q1FUr/J9qYw07gDpVPaQoP3lICCIstukwwy4a/psDziEEpeSK3F6Cnh0S3tSps JSvSVCn80cNyGB7Ht31OjQsAXT4DUPZYURaMKi4PlpVwOuK+cIrRTzgbG0/n0GLvNpIG 4k0A== X-Gm-Message-State: AIkVDXKSNtPU3fcEENTvwC6It8fnqHH2+cZmZc8wB9B31UTKIefjJJgxJRPz0UyUPo3jEg== X-Received: by 10.98.93.152 with SMTP id n24mr2652094pfj.107.1484042905435; Tue, 10 Jan 2017 02:08:25 -0800 (PST) Original-Received: from calancha-pc (217.225.128.101.dy.bbexcite.jp. [101.128.225.217]) by smtp.gmail.com with ESMTPSA id y62sm4191959pfk.52.2017.01.10.02.08.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2017 02:08:24 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:127955 Archived-At: After deletion of a large file from CVS, a diff shows a very large hunk with just deleted lines. Then, for unified diffs, a call to `diff-refine-hunk' on that hunk takes a huge time. Instead, it's better to first check if the hunk adds new lines: only when this is true, then proceed with the hunk refinement. emacs -Q M-! git diff ef8c9f8^ ef8c9f8 RET C-x o M-x diff-mode RET C-c C-b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From b3252092f8fdfc03c02d23022d901a625d183d89 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 10 Jan 2017 18:46:00 +0900 Subject: [PATCH] Refine an unified diff hunk only if adds lines * lisp/vc/diff-mode.el (diff-refine-hunk): Refine the hunk only when adds some new lines (Bug#25410). --- lisp/vc/diff-mode.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 9dfcd944bb..e045a5d974 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2075,22 +2075,23 @@ diff-refine-hunk (props-c '((diff-mode . fine) (face diff-refine-changed))) (props-r '((diff-mode . fine) (face diff-refine-removed))) (props-a '((diff-mode . fine) (face diff-refine-added)))) - (remove-overlays beg end 'diff-mode 'fine) - (goto-char beg) (pcase style (`unified - (while (re-search-forward - (eval-when-compile - (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?")) - (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re - "\\(\\)" - "\\(?:\\+.*\n\\)+" no-LF-at-eol-re))) - end t) - (smerge-refine-subst (match-beginning 0) (match-end 1) - (match-end 1) (match-end 0) - nil 'diff-refine-preproc props-r props-a))) + ;; Refine hunk only when it adds lines (Bug#25410). + (when (re-search-forward "^\\(?:\\+.*\n\\)+" end t) + (goto-char beg) + (while (re-search-forward + (eval-when-compile + (let ((no-LF-at-eol-re "\\(?:\\\\.*\n\\)?")) + (concat "^\\(?:-.*\n\\)+" no-LF-at-eol-re + "\\(\\)" + "\\(?:\\+.*\n\\)+" no-LF-at-eol-re))) + end t) + (smerge-refine-subst (match-beginning 0) (match-end 1) + (match-end 1) (match-end 0) + nil 'diff-refine-preproc props-r props-a)))) (`context (let* ((middle (save-excursion (re-search-forward "^---"))) (other middle)) -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.5) of 2017-01-09 Repository revision: ef8c9f8fc922b615aca91b47820d1f1900fddc96