From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov 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 21:25:10 +0400 Message-ID: <5006F176.10307@yandex.ru> References: <4FFB897D.7080303@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342632368 24888 80.91.229.3 (18 Jul 2012 17:26:08 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2012 17:26:08 +0000 (UTC) Cc: 11894@debbugs.gnu.org, Andreas Schwab To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 19:26:06 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 1SrY0f-0002Zs-Td for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 19:26:02 +0200 Original-Received: from localhost ([::1]:49751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrY0f-0001RC-88 for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 13:26:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrY0c-0001Qr-4i for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 13:25:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrY0a-0000Hq-Bj for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 13:25:58 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrY0a-0000HI-3N for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 13:25:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SrY6U-0002uu-BR for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 13:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jul 2012 17:32: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.134263268411168 (code B ref 11894); Wed, 18 Jul 2012 17:32:02 +0000 Original-Received: (at 11894) by debbugs.gnu.org; 18 Jul 2012 17:31:24 +0000 Original-Received: from localhost ([127.0.0.1]:48823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrY5r-0002u5-EA for submit@debbugs.gnu.org; Wed, 18 Jul 2012 13:31:23 -0400 Original-Received: from forward3.mail.yandex.net ([77.88.46.8]:60645) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrY5m-0002tv-4q for 11894@debbugs.gnu.org; Wed, 18 Jul 2012 13:31:21 -0400 Original-Received: from smtp1.mail.yandex.net (smtp1.mail.yandex.net [77.88.46.101]) by forward3.mail.yandex.net (Yandex) with ESMTP id 12389B41059; Wed, 18 Jul 2012 21:25:10 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1342632310; bh=xVBNTdd1jFTfV69eLVhlJhi8PJJbyj2k25d2ZYTbdaU=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=R+NEd26zX70Lb7DT27ALVZOzfdridBL4KvUs20rSxEKLScQT2VIpjV89JhgBVJGXZ 3uhG2iFUeuxhuQQmukTqXmcHMmklj0UrITTyRV26F6cW+33OkFThupgKwtb+IWhjhr 6JQSavwMhoPUoMX2PA+2MEKVoLgtElvHDNYmE2s4= Original-Received: from smtp1.mail.yandex.net (localhost [127.0.0.1]) by smtp1.mail.yandex.net (Yandex) with ESMTP id D52BAAA0317; Wed, 18 Jul 2012 21:25:09 +0400 (MSK) Original-Received: from 98-87.nwlink.spb.ru (98-87.nwlink.spb.ru [178.252.98.87]) by smtp1.mail.yandex.net (nwsmtp/Yandex) with ESMTP id P9AWaONl-P9AWuhZW; Wed, 18 Jul 2012 21:25:09 +0400 X-Yandex-Rcpt-Suid: monnier@IRO.UMontreal.CA X-Yandex-Rcpt-Suid: 11894@debbugs.gnu.org X-Yandex-Rcpt-Suid: schwab@linux-m68k.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1342632309; bh=xVBNTdd1jFTfV69eLVhlJhi8PJJbyj2k25d2ZYTbdaU=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=F3hBFOfPUDC32UbqxsWm8jRAsEx8iGuTS+Wmn3+dVGGW2E0Ygy1cNJ6awjRpaBZqa P/6fLoPLB6HC1eih59YnTk0G8qJvvl/gIvZ3D3QrcwkL0foOAC49GOdAdJf7OdQIqU oCcL8NlD3Rl3DP0+ysaVBWvG1rJjBd0kA6wsua2k= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: 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:62125 Archived-At: On 18.07.2012 16:53, Stefan Monnier wrote: >> 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. As per Andreas' comment, this is probably not a bug. >> 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 ;-) Yep, and I'll use it as a workaround if this bug won't be fixed. >> 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 > % `info diff` says: "For proper operation, `patch' typically needs at least two lines of context.", so this just may be a documented problem nobody cares about. >> - (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. I'm fine either way, just wanted to report this. --Dmitry