From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11894: 24.1.50; [PATCH] diff-apply-hunk can be off by 1 line when the hunk is 0-context pure removal Date: Wed, 18 Jul 2012 08:53:15 -0400 Message-ID: References: <4FFB897D.7080303@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342616052 12544 80.91.229.3 (18 Jul 2012 12:54:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2012 12:54:12 +0000 (UTC) Cc: 11894@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 14:54:11 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SrTlV-0003nW-3e for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 14:54:05 +0200 Original-Received: from localhost ([::1]:53348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTlU-0003RC-H2 for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 08:54:04 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTlO-0003R6-UW for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:54:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrTlN-0006YG-Sc for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:53:58 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTlN-0006YA-PU for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:53:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SrTrG-0000Zk-Gv for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 09:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jul 2012 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11894 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 11894-submit@debbugs.gnu.org id=B11894.13426163682148 (code B ref 11894); Wed, 18 Jul 2012 13:00:02 +0000 Original-Received: (at 11894) by debbugs.gnu.org; 18 Jul 2012 12:59:28 +0000 Original-Received: from localhost ([127.0.0.1]:47700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrTqh-0000Ya-TP for submit@debbugs.gnu.org; Wed, 18 Jul 2012 08:59:28 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:46537) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrTqe-0000YS-Pw for 11894@debbugs.gnu.org; Wed, 18 Jul 2012 08:59:25 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q6ICrHAN023960; Wed, 18 Jul 2012 08:53:17 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 39003AECAF; Wed, 18 Jul 2012 08:53:15 -0400 (EDT) In-Reply-To: <4FFB897D.7080303@yandex.ru> (Dmitry Gutov's message of "Tue, 10 Jul 2012 05:46:37 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4282=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4282> : streams <786686> : uri <1168460> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62096 Archived-At: > Not sure if we can rely on the line number being always off by 1 in such > hunks (there's no insertion, so, technically, the second line number in the > header could be arbitrary), but at least 3 versions of diff across > 2 different OSes work the same in this regard. This looks like a bug in those versions of diff (not that I know a non-buggy version, tho). Could you report it to GNU diffutils. > Note that if you try to create such hunk with `diff-split-hunk' (by slicing > it off a bigger hunk), the line number won't be off by 1. Oh, right, so there is a "version of diff" that doesn't have this bug ;-) > Maybe that's a bug in `diff-split-hunk'. I doubt it. At least `patch' seems to agree with diff-mode.el: % diff -c0 footest1 footest2 |patch -o footest3 footest1 patching file footest1 patch: **** replacement text or line numbers mangled in hunk at line 8 % > - (goto-char (point-min)) (forward-line (1- (string-to-number line))) > + (let ((line-num (string-to-number line))) > + ;; When the hunk is pure deletion, line number is off by 1. > + (when (string= (if reverse (car old) (car new)) "") > + (incf line-num)) > + (goto-char (point-min)) (forward-line (1- line-num))) Context/unified diffs with 0 context are pretty rare, so I'd rather not work around such a bug if I don't really have to. Stefan