Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 64707 - diff-mode can't find a hunk
diff-mode can't find a hunk
Product: Red Hat Raw Hide
Classification: Retired
Component: emacs (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jens Petersen
Aaron Brown
: MoveUpstream
Depends On:
  Show dependency treegraph
Reported: 2002-05-09 16:30 EDT by Jonathan Kamens
Modified: 2007-04-18 12:42 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-09-29 04:20:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
sample patch file showing the bug (270 bytes, patch)
2002-05-09 16:31 EDT, Jonathan Kamens
no flags Details | Diff

  None (edit)
Description Jonathan Kamens 2002-05-09 16:30:58 EDT
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 16:31:14 EDT
Created attachment 56849 [details]
sample patch file showing the bug
Comment 2 Trond Eivind Glomsrxd 2002-05-10 15:50:55 EDT
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 17:43:03 EDT
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 17:46:54 EDT
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-12 20:44:52 EDT
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 @@
--- c	Thu May  9 15:47:32 2002
+++ d	Thu May  9 15:47:34 2002
@@ -1,2 +1,2 @@
--- e	Thu May  9 15:47:32 2002
+++ f	Thu May  9 15:47:34 2002
@@ -1,2 +1,2 @@
Comment 6 Trond Eivind Glomsrxd 2002-05-15 15:03:16 EDT
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 @@
--- c	Wed May 15 14:44:59 2002
+++ d	Wed May 15 14:45:03 2002
@@ -1 +1 @@
--- e	Wed May 15 14:44:59 2002
+++ f	Wed May 15 14:45:03 2002
@@ -1 +1 @@

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 @@
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 @@
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 @@

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 15:10:02 EDT
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 17:43:08 EST
Yeah, looks like diff-mode assumes patch files are in the format
output by "diff -r"...
Comment 9 Jens Petersen 2004-01-14 03:15:08 EST
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 04:20:58 EDT
Reported upstream on emacs-devel list.

Note You need to log in before you can comment on or make changes to this bug.