Received: (at 80040) by debbugs.gnu.org; 20 Dec 2025 19:09:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 14:09:35 2025 Received: from localhost ([127.0.0.1]:53350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1vX2Kc-0005Yp-Lb for submit <at> debbugs.gnu.org; Sat, 20 Dec 2025 14:09:34 -0500 Received: from mail-out.m-online.net ([2001:a60:0:28:0:1:25:1]:42466) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <whitebox@HIDDEN>) id 1vX2KZ-0005Ye-VA for 80040 <at> debbugs.gnu.org; Sat, 20 Dec 2025 14:09:33 -0500 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by mail-out.m-online.net (Postfix) with ESMTP id 4dYYqY4tYYz1wMZ2; Sat, 20 Dec 2025 20:09:29 +0100 (CET) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4dYYqX1yMsz1wMZ1; Sat, 20 Dec 2025 20:09:27 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4dYYqW5vS0z1qqlS; Sat, 20 Dec 2025 20:09:27 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id Wuc2b3ce1Y1x; Sat, 20 Dec 2025 20:09:18 +0100 (CET) X-Auth-Info: oH87F8BmzAldtXAXHXSoBFMnJwH+3g/GFb5hp13uUiIPaBdNGulZdrAvCr/z3GN0 Received: from igel.home (aftr-82-135-83-43.dynamic.mnet-online.de [82.135.83.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 20 Dec 2025 20:09:18 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id A035A2C225B; Sat, 20 Dec 2025 20:09:17 +0100 (CET) From: Andreas Schwab <schwab@HIDDEN> To: Sean Whitton <spwhitton@HIDDEN> Subject: Re: bug#80040: 30.2; diff-sanity-check-hunk false positive on "\ No newline at end, of file" In-Reply-To: <875xa1gprp.fsf@HIDDEN> (Sean Whitton's message of "Sat, 20 Dec 2025 15:02:34 +0000") References: <ff66c0c2-f630-4438-9981-5d3a234404ba@HIDDEN> <875xa1gprp.fsf@HIDDEN> Date: Sat, 20 Dec 2025 20:09:17 +0100 Message-ID: <87jyyhotr6.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 80040 Cc: 80040 <at> debbugs.gnu.org, Kevin Montag <kmontag@HIDDEN>, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) On Dez 20 2025, Sean Whitton wrote: > diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el > index a7d92039889..d6c7ae46a1c 100644 > --- a/lisp/vc/diff-mode.el > +++ b/lisp/vc/diff-mode.el > @@ -1913,6 +1913,7 @@ diff-sanity-check-hunk > (eq (char-after) ?\n) > (> before 0) (> after 0)) > (decf before) (decf after) t) > + ((looking-at "\\\\ No newline at end of file$") t) The text is locale dependent, it should only check for the backslash. -- Andreas Schwab, schwab@HIDDEN GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
bug-gnu-emacs@HIDDEN:bug#80040; Package emacs.
Full text available.
Received: (at 80040) by debbugs.gnu.org; 20 Dec 2025 18:43:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 13:43:36 2025
Received: from localhost ([127.0.0.1]:53133 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1vX1vT-00042a-OK
for submit <at> debbugs.gnu.org; Sat, 20 Dec 2025 13:43:36 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58830)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
id 1vX1vR-00042D-DU
for 80040 <at> debbugs.gnu.org; Sat, 20 Dec 2025 13:43:33 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CF0D7441570;
Sat, 20 Dec 2025 13:43:27 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
s=mail; t=1766256206;
bh=tfTxMc7kpAbMT3QWmz3kdBJBM1iFEviYpQpp6BsgXDA=;
h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
b=hMyJMZySFJvyqq53ZWfklmjqzp6PE8+8bnFTaM4AyJzznTyKmQVo3wjtfCCivvrIy
jPC6aUfhusKyTCs1B0PVcSH7Wh5fWowZRb4TGAPZLHChRQ8u9qZ/hSpybqe3rexAO5
c6GE4wvjpSblNWOVOkFAPkgjc/f73REvi0NoveHxCl/ZAibXzokjPXKdiPFm9y8JLU
TcNoU/lCocsaT4zJGbwUJsYmd/PUR7s/H0Tkbw/wuE+4IyX6DvUB/y4nO7EvhFihdg
z9xUqdHoypPT4232H188bKkOHd9B5j2Hkn7Tw5IkkexLb58RJUhPmL95Qs9HcYb6+7
CC1QkVy80bcJQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A87A8441562;
Sat, 20 Dec 2025 13:43:26 -0500 (EST)
Received: from pastel (104-195-235-55.cpe.teksavvy.com [104.195.235.55])
by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 76C87120280;
Sat, 20 Dec 2025 13:43:26 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
Subject: Re: bug#80040: 30.2; diff-sanity-check-hunk false positive on "\ No
newline at end, of file"
In-Reply-To: <875xa1gprp.fsf@HIDDEN>
Message-ID: <jwvtsxldmgr.fsf-monnier+emacs@HIDDEN>
References: <ff66c0c2-f630-4438-9981-5d3a234404ba@HIDDEN>
<875xa1gprp.fsf@HIDDEN>
Date: Sat, 20 Dec 2025 13:43:25 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results: 0
ALL_TRUSTED -1 Passed through trusted hosts only via SMTP
AWL -0.199 Adjusted score from AWL reputation of From: address
BAYES_00 -1.9 Bayes spam probability is 0 to 1%
DKIM_SIGNED 0.1 Message has a DKIM or DK signature,
not necessarily valid
DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
domain
DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
domain
X-SPAM-LEVEL:
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80040
Cc: 80040 <at> debbugs.gnu.org, Kevin Montag <kmontag@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
> Thanks. I think this is an appropriate fix, though Stefan's review
> would be appreciated:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
> index a7d92039889..d6c7ae46a1c 100644
> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -1913,6 +1913,7 @@ diff-sanity-check-hunk
> (eq (char-after) ?\n)
> (> before 0) (> after 0))
> (decf before) (decf after) t)
> + ((looking-at "\\\\ No newline at end of file$") t)
> ((and (zerop before) (zerop after)) nil)
> ((or (< before 0) (< after 0))
> (error (if (or (zerop before) (zerop after))
> --8<---------------cut here---------------end--------------->8---
Ideally, we'd check that it occurs at the end of the hunk, but the
definition of "end" is a bit subtle, so it's probably not worth
the trouble.
IOW: LGTM, thanks,
Stefan
bug-gnu-emacs@HIDDEN:bug#80040; Package emacs.
Full text available.
Received: (at 80040) by debbugs.gnu.org; 20 Dec 2025 15:02:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 10:02:47 2025
Received: from localhost ([127.0.0.1]:50663 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1vWyTn-0003et-Ir
for submit <at> debbugs.gnu.org; Sat, 20 Dec 2025 10:02:47 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:45294)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
id 1vWyTk-0003ec-BE
for 80040 <at> debbugs.gnu.org; Sat, 20 Dec 2025 10:02:45 -0500
DKIM-Signature: a=rsa-sha256;
b=Qhc5tlVuh7Ls+tIRRJys3U9Khoec1zh73RZUucqzfDGBNorLaI5c0qbrx1n4R3x94+AqfXq2Gx2chP29GNx8h/IxZtaKlAafFw0jGPeCuzaSWehC9kEOXhC5EEwFX2POxp0ev5i4/NBh3PymuoPTPrPMFhl1uyGWpqOlOlXFMhKrOBRE7F2HViPiAXqNemSCm1Ah1STwXlPjJpu+adf2Y+ybkOdNE734TNb++3JMEQN6FHIwjUbEHyGtGy6Fe9q5Ow1xzMRLPPRefvF/xNyAYeKVn1/7tqJdGe7oEe0cJoFVRrz4YtZGN9sXanKe8rLyu2HOQkFpOChf9MHkuP7qVQ==;
s=purelymail2; d=spwhitton.name; v=1;
bh=tCAapS/vAdY+CrVgXnGwuNtXnPU+w/OE5+K02kVXkHY=;
h=Received:Received:From:To:Subject:Date;
DKIM-Signature: a=rsa-sha256;
b=DyIMakiFmlSIhxXxLm4nHoep7WQ/BdNMmvELO0n9BBFgVIF4jQy153GS6tUoJDGnQIZU3U/U3si6JW+CT49zqvKp6E+RCeLolmIaCrbN9zt4tZrcw0lmXbnl5SeFB/E2fj4VmRVx/P6nGMnRs1FzIlrC8Z4Qud/D7O1uwttnpO+yzYK1Wza6Ky8DGEBkyYBUE4e9JIJ4rU52HxQ4VzpaHrwLMzmWKM6UtMjqtRJ6R/ly82tUV+ACmw3AmoxhN6lRjD9O67B1uB6wpese4p2CqJ7esUu1bkfysOZTAL8EnaA8C/1YP8DxTSxj8pSRoV0Y+u+CQMQeLd3XCNwoEf8z3A==;
s=purelymail2; d=purelymail.com; v=1;
bh=tCAapS/vAdY+CrVgXnGwuNtXnPU+w/OE5+K02kVXkHY=;
h=Feedback-ID:Received:Received:From:To:Subject:Date;
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 80040 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 461049938;
(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
Sat, 20 Dec 2025 15:02:35 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
id 72AC39407A0; Sat, 20 Dec 2025 15:02:34 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: Kevin Montag <kmontag@HIDDEN>, Stefan Monnier
<monnier@HIDDEN>
Subject: Re: bug#80040: 30.2; diff-sanity-check-hunk false positive on "\ No
newline at end, of file"
In-Reply-To: <ff66c0c2-f630-4438-9981-5d3a234404ba@HIDDEN>
References: <ff66c0c2-f630-4438-9981-5d3a234404ba@HIDDEN>
Date: Sat, 20 Dec 2025 15:02:34 +0000
Message-ID: <875xa1gprp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 80040
Cc: 80040 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
Hello,
On Sat 20 Dec 2025 at 12:39am +01, Kevin Montag wrote:
> When running `diff-sanity-check-hunk` on a diff hunk containing "\ No
> newline at end of file" in the middle (like, for example, the shell
> output of `diff -u <(printf 'old') <(printf 'new')`), the user is
> prompted to "Try to auto-fix word wrap damage?".
>
> If the user says yes to this prompt, the "\ No newline at end of file"
> is simply moved up to the end of the previous line, i.e. treated as if
> the previous line was accidentally wrapped.
>
> This indirectly breaks e.g. `diff-apply-hunk`, which fails if the user
> chooses to "fix" the damage, or aborts if they choose not to.
Thanks. I think this is an appropriate fix, though Stefan's review
would be appreciated:
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index a7d92039889..d6c7ae46a1c 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1913,6 +1913,7 @@ diff-sanity-check-hunk
(eq (char-after) ?\n)
(> before 0) (> after 0))
(decf before) (decf after) t)
+ ((looking-at "\\\\ No newline at end of file$") t)
((and (zerop before) (zerop after)) nil)
((or (< before 0) (< after 0))
(error (if (or (zerop before) (zerop after))
--8<---------------cut here---------------end--------------->8---
--
Sean Whitton
bug-gnu-emacs@HIDDEN:bug#80040; Package emacs.
Full text available.Received: (at submit) by debbugs.gnu.org; 20 Dec 2025 08:07:21 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 03:07:20 2025 Received: from localhost ([127.0.0.1]:46251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1vWrzi-0007D7-8B for submit <at> debbugs.gnu.org; Sat, 20 Dec 2025 03:07:20 -0500 Received: from lists.gnu.org ([2001:470:142::17]:34842) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <kmontag@HIDDEN>) id 1vWk4i-00047K-PA for submit <at> debbugs.gnu.org; Fri, 19 Dec 2025 18:39:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <kmontag@HIDDEN>) id 1vWk4a-0002lJ-Ts for bug-gnu-emacs@HIDDEN; Fri, 19 Dec 2025 18:39:48 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <kmontag@HIDDEN>) id 1vWk4X-00021z-FZ for bug-gnu-emacs@HIDDEN; Fri, 19 Dec 2025 18:39:48 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-64b4f730a02so3563932a12.0 for <bug-gnu-emacs@HIDDEN>; Fri, 19 Dec 2025 15:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766187582; x=1766792382; darn=gnu.org; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:from:to:cc:subject :date:message-id:reply-to; bh=tdFZj8eAxZzWqOVfg6b2SdEaAPe7IJ4o8oCg0vUhqK8=; b=PqEN6WSTc02CVZGiYmlCtmjAqhJ/US8WCLXTrPDJVQ0/JVO5xW45FTD3GcT/5BQ2xD 1Q44CA5JJrKVfXat+2xC0/IDH4zFdhhH82Hv/WaqReQa8cTmd1woEbO6jfBBA0f6DL/4 8wzC21McCOFVMe62kdOQMsmP0Rtln6jhzruR8t+sNFtXZTnu6bY04aDBHeGRHF/uZmu4 S6SAtvoUDHvQYfgsVCW9AeMwuLcu9KipOHSs5/sRABfk+t8DkPwcQfy1cDMgXaFMoexm ANM+49CL59eS7ghrLXDe7surEPCF0FR/sSyIGnEwdUYpNBOkF0D2aO5YFQoZuIcCrs9f 9F0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766187582; x=1766792382; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tdFZj8eAxZzWqOVfg6b2SdEaAPe7IJ4o8oCg0vUhqK8=; b=qw+6PXoI8BdgaoOroTK9XHTlUpQSF6yA51+tGO06hOFQIHAd5eqOxd5s4BWRltRqd+ 0ZngLlPMCGtCV42R1dCKC6gXrsWhw+py+CojZmFISoZI2f1nNwKzdh55pMV/R1RGwUCt qXlMqye62xanuR0saqU6leemirg06J2MsSY6RMiDj7baHarBlaX3brVsaUJrzoLR7zPv /6RJBHE/7Wj1yuBK90xOunuX5n/8D1VXNGYdmQSqPlxTxqzcN1XSON8UEHGd5ske/s8t 8NiasEGupysyEPdVvFxgFEs8n6JWQJ0kmj86PyB7AnAWCuwWJDmM1g9senh2Zoy0qFjZ oCwg== X-Gm-Message-State: AOJu0YxTK6/L3Kz4onFBK3vuAVidldtltsXq7IGc+qMi49tvsZAMtOjW wjP1pC6Il2UaPOrCTTCwKOREDJ1RVf/CjV1Mx1V4IOn2JrY8FpHMqh/rrtBL1A== X-Gm-Gg: AY/fxX7XuGr+shi6RhExbpr2U6D0bfFBYo3AMHXzdS25+Rz7SdwAaboJbPkUHEBS0ap wLoZyWjNVCZcJi1q2oITv83qHjmLzEvUvu8bO3vKIHU1G8X3XP2f/HeLrgudBDMpHWSGeCB6kAz DrKL8fCbKGm8WHbo6ld2Fnk5yRo7anmaydG+GxeJfm/yUFP7umZezNT2yfGEcyElGB24Uih2uA6 2l+bdCbFsQ4W+Vg6CkxfhcoOwajmvC0+JnXGfHRrxco1kI6/U/i0Va8oVCPPsqOL7bHcwQ7zgpV Sz6CDk5ulpmLUmBP2y8ykMtlx5y4DKNRqdsZlbzR2htjBK6e9CJ9QoaLHFgGBoKeBk1bpj7F7jk cRw4X7A4g7Y/X8+NqFnyCJ4zHTWWddDqO6Y7IX6dYWTKnK0cu6/0BdunG2s42SzMJ51ZEyZ9r/O FA8IP5t0itA7GRtw== X-Google-Smtp-Source: AGHT+IHbuCyMACpGWLvNTBfOhddcGNA7NgWFrxPWt2kIireN6RCBAyRLmyz7VFDsAcIkO2M+kVkaQw== X-Received: by 2002:a05:6402:2683:b0:64b:4624:777d with SMTP id 4fb4d7f45d1cf-64b8eefb5a2mr4041293a12.18.1766187581684; Fri, 19 Dec 2025 15:39:41 -0800 (PST) Received: from [10.2.0.2] ([194.126.177.90]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64b916b66e2sm3391577a12.34.2025.12.19.15.39.41 for <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Dec 2025 15:39:41 -0800 (PST) Message-ID: <ff66c0c2-f630-4438-9981-5d3a234404ba@HIDDEN> Date: Sat, 20 Dec 2025 00:39:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: bug-gnu-emacs@HIDDEN From: Kevin Montag <kmontag@HIDDEN> Subject: 30.2; diff-sanity-check-hunk false positive on "\ No newline at end, of file" Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=kmontag@HIDDEN; helo=mail-ed1-x533.google.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 20 Dec 2025 03:07:16 -0500 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) When running `diff-sanity-check-hunk` on a diff hunk containing "\ No newline at end of file" in the middle (like, for example, the shell output of `diff -u <(printf 'old') <(printf 'new')`), the user is prompted to "Try to auto-fix word wrap damage?". If the user says yes to this prompt, the "\ No newline at end of file" is simply moved up to the end of the previous line, i.e. treated as if the previous line was accidentally wrapped. This indirectly breaks e.g. `diff-apply-hunk`, which fails if the user chooses to "fix" the damage, or aborts if they choose not to. Here's a simple reproduction: ```elisp (require 'diff-mode) ;; This works fine - newline at end of old content. (with-temp-buffer ;; Diff as generated by e.g.: ;; ;; diff -u <(printf 'old\n') <(printf 'new') ;; (insert "diff --git a/test.txt b/test.txt --- a/test.txt +++ b/test.txt @@ -1 +1 @@ -old +new \\ No newline at end of file ") (diff-mode) (goto-char (point-min)) (re-search-forward "^@@") (beginning-of-line) ;; No issue. (diff-sanity-check-hunk)) ;; This throws a false-positive sanity check error. (with-temp-buffer ;; Diff as generated by e.g.: ;; ;; diff -u <(printf 'old') <(printf 'new') ;; (insert "diff --git a/test.txt b/test.txt --- a/test.txt +++ b/test.txt @@ -1 +1 @@ -old \\ No newline at end of file +new \\ No newline at end of file ") (diff-mode) (goto-char (point-min)) (re-search-forward "^@@") (beginning-of-line) ;; Prompts to fix word-wrap damage. (diff-sanity-check-hunk)) ``` Note that if `diff-sanity-check-hunk` is redefined as a no-op, `diff-apply-hunk` does seem to work fine on patches of this form. In GNU Emacs 30.2 (build 2, aarch64-apple-darwin25.0.0, NS appkit-2685.10 Version 26.0.1 (Build 25A362)) of 2025-11-12 built on shine.local System Description: macOS 26.0.1 Configured using: 'configure --disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp --infodir=/opt/homebrew/Cellar/emacs-plus@30/30.2/share/info/emacs --prefix=/opt/homebrew/Cellar/emacs-plus@30/30.2 --with-native-compilation=aot --with-xml2 --with-gnutls --without-compress-install --with-dbus --with-imagemagick --with-modules --with-rsvg --with-webp --with-xwidgets --with-ns --disable-ns-self-contained 'CFLAGS=-O2 -DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/gcc/include -I/opt/homebrew/opt/libgccjit/include' 'LDFLAGS=-L/opt/homebrew/opt/sqlite/lib -L/opt/homebrew/lib/gcc/15 -Wl,-rpath,/opt/homebrew/lib/gcc/15'' Configured features: ACL DBUS GIF GLIB GMP GNUTLS IMAGEMAGICK JPEG LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM XWIDGETS ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix
Kevin Montag <kmontag@HIDDEN>:bug-gnu-emacs@HIDDEN.
Full text available.bug-gnu-emacs@HIDDEN:bug#80040; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.