GNU bug report logs - #43297
27.1; corrupts patch when diff-update-on-the-fly is set to nil

Previous Next

Package: emacs;

Reported by: Mark H Weaver <mhw <at> netris.org>

Date: Wed, 9 Sep 2020 19:53:01 UTC

Severity: normal

Tags: confirmed

Found in version 27.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Daniel Martín <mardani29 <at> yahoo.es>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 43297 <at> debbugs.gnu.org
Subject: bug#43297: 27.1; corrupts patch when diff-update-on-the-fly is set to nil
Date: Wed, 21 Dec 2022 11:28:54 +0100
Mark H Weaver <mhw <at> netris.org> writes:

> I don't know if this behavior is new in 27.1, but that's the only
> version I've tried this on.
>
> When I set 'diff-update-on-the-fly' to nil, I find that some patches are
> consistently corrupted when I save them while in diff-mode.  See below
> for an example patch that demonstrates this behavior.
>
> To reproduce:
>
> * Save the example patch below to "test.patch", and make another copy
>   in "test2.patch".
>
> * Launch "emacs -nw -q"  (I used Emacs 27.1)
>
> * Evaluate (setq diff-update-on-the-fly nil)
>
> * Find file "test2.patch".
>
> * Add a character anywhere in the buffer and then delete it, such that
>   the buffer is now in a "modified" state.
>
> * Save the file.
>
> * Run "diff -u test.patch test2.patch" in the shell.
>
> * Here's the result that I see:
>
> --- test.patch
> +++ test2.patch
> @@ -39,7 +39,7 @@
>   
>   	var elements = document.getElementsByTagName("style");
>   	for(var i = 0; i < elements.length; i++){
> -@@ -41,16 +48,20 @@ function reveal_css(){
> +@@ -41,17 +48,20 @@ function reveal_css(){
>   
>   		}
>   	}
>
>
> Emacs corrupts the line count of the final hunk, making it one larger
> than it should be (17 instead of 16).  This breaks the patch, such that
> attempts to apply it will fail.

I've tried to reproduce this bug in an Emacs build from the current
master branch and I couldn't.  Could you try a recent build of Emacs and
confirm if it's also fixed for you?  Thanks.




This bug report was last modified 160 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.