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#17522: diff-mode frustrates attempt to correct corrupted diff file. Date: Wed, 21 May 2014 21:32:11 -0400 Message-ID: References: <20140518105055.GA3727@acm.acm> <20140521215636.GA3908@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400722410 31356 80.91.229.3 (22 May 2014 01:33:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 May 2014 01:33:30 +0000 (UTC) Cc: 17522@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 22 03:33:23 2014 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 1WnHsn-0000In-4M for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 May 2014 03:33:21 +0200 Original-Received: from localhost ([::1]:34301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnHsm-0000Ud-OX for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 May 2014 21:33:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnHsc-0000UL-Dj for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 21:33:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnHsU-0006AY-V6 for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 21:33:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnHsU-0006AU-ST for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 21:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WnHsU-0004Hj-Ik for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 21:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 May 2014 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17522 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17522-submit@debbugs.gnu.org id=B17522.140072234216401 (code B ref 17522); Thu, 22 May 2014 01:33:02 +0000 Original-Received: (at 17522) by debbugs.gnu.org; 22 May 2014 01:32:22 +0000 Original-Received: from localhost ([127.0.0.1]:55716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WnHrp-0004GT-3O for submit@debbugs.gnu.org; Wed, 21 May 2014 21:32:21 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:44271) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WnHrl-0004G4-SM for 17522@debbugs.gnu.org; Wed, 21 May 2014 21:32:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+KQe/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCwsOJhIUGA0kiAQI0hkXjhgRAVAHhDgEqRmBaoNMIYE1 X-IPAS-Result: ArUGAIDvNVPO+KQe/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCwsOJhIUGA0kiAQI0hkXjhgRAVAHhDgEqRmBaoNMIYE1 X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="63613485" Original-Received: from 206-248-164-30.dsl.teksavvy.com (HELO pastel.home) ([206.248.164.30]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 21 May 2014 21:32:11 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 56E7B601F5; Wed, 21 May 2014 21:32:11 -0400 (EDT) In-Reply-To: <20140521215636.GA3908@acm.acm> (Alan Mackenzie's message of "Wed, 21 May 2014 21:56:36 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:89339 Archived-At: >> Maybe not a bug, but a misfeature: the ",0" is probably because the first >> line after the @...@ is empty, which normally "can't" be part of a hunk, >> so this empty line is taken as an "end of hunk". > OK. But patch appears to accept a blank line (in a unified diff) > without complaint. Indeed, "patch" at some point was changed so as to accept empty lines. diff-mode.el was partly changed to accommodate that looser format, but not 100% (and in the case of updating line counts while editing the patch, it's a bit more delicate since, contrary to "patch" we can't rely on the line counts to decide whether an empty line marks the end of a hunk or not). >> If you add a space on that line, the count should be updated again and >> start looking more sane. > This is all besides the point. I did not edit the hunk header, > therefore I don't expect it to be changed behind my back. If I need > the header to be recalculated, surely there should be a command > for that. diff-mode tries to be fancier and do that transparently. You're just bumping into a bug of that code (regardless of how the empty-line is handled, a line count of 0 for both sides of the hunk is clearly not right). > Why do people hand edit patches anyway? All kinds of reasons. The case of corrupted patches was definitely not the main motivation for the line-count-update feature (after all, for corrupted patches, you don't want to mess with the line counts). BTW, I remember writing some kind of "fix corrupted hunk" code. Oh, yes, it's in diff-sanity-check-hunk. Can you try to see if it can auto-fix your corrupted patch? M-x diff-goto-source RET is probably the easiest way to trigger it (sadly, it's not provided as a separate command). > Clearly, because patches sometimes get corrupted, e.g. by email > software, as happened to me. For this case, it doesn't make sense to > recalculate the header. But for other reasons? It can be easier to take a hunk and edit it to remove some of the changes it performs, then it is to change the source code to then re-generate a new hunk. Stefan