Bug 64707

Summary: diff-mode can't find a hunk
Product: [Retired] Red Hat Raw Hide Reporter: Jonathan Kamens <jik>
Component: emacsAssignee: Jens Petersen <petersen>
Status: CLOSED UPSTREAM QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0Keywords: MoveUpstream
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-29 08:20:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
sample patch file showing the bug none

Description Jonathan Kamens 2002-05-09 20:30:58 UTC
Load the attached file into emacs.  Run C-x C-q to make it read-write.  Put your
cursor on the first "@@" and type ESC k to kill that hunk.  It deletes the whole
buffer instead of deleting just that hunk.

Comment 1 Jonathan Kamens 2002-05-09 20:31:14 UTC
Created attachment 56849 [details]
sample patch file showing the bug

Comment 2 Trond Eivind Glomsrxd 2002-05-10 19:50:55 UTC
Works for me when tested with a valid patch file and not the same hunk repeated
three times.

Comment 3 Jonathan Kamens 2002-05-10 21:43:03 UTC
It's not the same hunk repeated over and over.  It's three different patches to
three different files.  The fact that I used the same diff over and over in my
example is irrelevant; the problem will occur even with an actual patch
containing all different files as wel.


Comment 4 Trond Eivind Glomsrxd 2002-05-10 21:46:54 UTC
No, it's all from a to b in your case. When I tested it on a valid patch file
(samba-2.2.2-winsfixes.patch, from the samba package) it worked.

Comment 5 Jonathan Kamens 2002-05-13 00:44:52 UTC
This is becoming somewhat tiresome :-).

If I fix that which you claim makes my patch file "invalid" by replacing the
second "a...b" with "c...d" and the third with "e...f", thus ostensibly
producing a patch file which patches three different files, the problem still
occurs.  That is, I load the file into Emacs, make it writable with C-x C-q,
move to the third line, and type ESC k, and the entire buffer, rather than just
one hunk, disappears.

I'm using emacs-21.2-4.

The fact that you are unable to reproduce the problem with one specific patch
file is irrelevant.  I'm not claiming that it never works; I'm claiming that it
doesn't work with the particular valid patch file I've submitted to you.

Here's my modified patch file, which as far as I can tell is not in any way
"invalid" and yet exhibits this problem:

--- a	Thu May  9 15:47:32 2002
+++ b	Thu May  9 15:47:34 2002
@@ -1,2 +1,2 @@
-foo
+bar
 
--- c	Thu May  9 15:47:32 2002
+++ d	Thu May  9 15:47:34 2002
@@ -1,2 +1,2 @@
-foo
+bar
 
--- e	Thu May  9 15:47:32 2002
+++ f	Thu May  9 15:47:34 2002
@@ -1,2 +1,2 @@
-foo
+bar
 


Comment 6 Trond Eivind Glomsrxd 2002-05-15 19:03:16 UTC
FWIW, if I'm using the following file:

--- a	Wed May 15 14:44:59 2002
+++ b	Wed May 15 14:45:03 2002
@@ -1 +1 @@
-foo
+bar
--- c	Wed May 15 14:44:59 2002
+++ d	Wed May 15 14:45:03 2002
@@ -1 +1 @@
-foo
+bar
--- e	Wed May 15 14:44:59 2002
+++ f	Wed May 15 14:45:03 2002
@@ -1 +1 @@
-foo
+bar

I can reproduce it. This is a catted together patch file, and you couldn't get
it in any other way... The similar file,

diff -uNr foo4/a foo5/a
--- foo4/a	Wed May 15 14:56:12 2002
+++ foo5/a	Wed May 15 14:56:33 2002
@@ -1 +1 @@
-foo
+bar
diff -uNr foo4/b foo5/b
--- foo4/b	Wed May 15 14:56:20 2002
+++ foo5/b	Wed May 15 14:56:35 2002
@@ -1 +1 @@
-foo
+bar
diff -uNr foo4/c foo5/c
--- foo4/c	Wed May 15 14:56:21 2002
+++ foo5/c	Wed May 15 14:56:37 2002
@@ -1 +1 @@
-foo
+bar

which does the same thing and is produced by diff, works.

Do you have a real life, known good patch file producing this behaviour?


Comment 7 Jonathan Kamens 2002-05-15 19:10:02 UTC
The patch file I sent you is most certainly a "good" patch file.  If you create
files a, c and e with the contents shown in the patch and then run "patch <
foo.patch", patch will happy modify a, c and e with no complaints.  Diff-mode is
not the final arbiter of what is and isn't a valid patch file; patch is.  If
diff-mode doesn't work with path files that don't have "diff" lines in them,
then diff-mode is broken, not the patch files.

"diff -r" is only one of many ways to produce patch files.  the "diff" lines in
patch files produced by "diff -r" are extra information inserted by "diff -r";
they are certainly not required to make a patch file "valid".


Comment 8 Jens Petersen 2002-10-30 22:43:08 UTC
Yeah, looks like diff-mode assumes patch files are in the format
output by "diff -r"...

Comment 9 Jens Petersen 2004-01-14 08:15:08 UTC
Still occurs with 21.3.  Again I think upstream is the
best place to deal with this.

Do you have examples of this type of patch occuring in the wild btw?

Comment 10 Jens Petersen 2004-09-29 08:20:58 UTC
Reported upstream on emacs-devel list.