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.
Created attachment 56849 [details] sample patch file showing the bug
Works for me when tested with a valid patch file and not the same hunk repeated three times.
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.
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.
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
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?
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".
Yeah, looks like diff-mode assumes patch files are in the format output by "diff -r"...
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?
Reported upstream on emacs-devel list.