Community
Participate
Working Groups
Created attachment 121217 [details] example_v01 There is a difference between Unix "patch" command and Eclipse "apply patch". Steps to reproduce: 1. Take the example from attachment 2. Apply it in Eclipse to any empty file, using "Apply patch" 3. Apply it to empty file using Unix "patch" command Result: A. When using "Apply patch" You will get a file containing 2 lines, one with "xxx" and another one empty. B. When using "patch" command You will get a file containing 1 line with "xxx" (no newline at end of file). Unix 'diff' and 'patch' commands does not use '/no newline at end of file' marker. They are using the basic '+' and '-' to give all the information. So Eclipse 'apply patch' isn't fully compatible with Unix 'diff -u' command.
Incomplete lines with GNU diff is described here: http://www.network-theory.co.uk/docs/diff/Incomplete_Lines.html According to: http://www.network-theory.co.uk/docs/diff/Line_Formats.html we may read: "The default line format is ‘%l’ followed by a newline character" Eclipse use as default '%L' line format, and this is the reason, why Eclipse and GNU diff aren't fully compatible.
Sorry for problems with encoding. Corrected line: (...) "The default line format is '%l' followed by a newline character" (...)
If you want to fix this issue I believe you should start from looking at the PatchReader[1] class. Then you could identify the piece of code responsible for processing the last line of a file in the patch. I guess we wouldn't get away with changing the way apply patch works but when you isolate the code for it we could replace it with something like this: if (true) { // expect "no newline" marker at the end of a file } else { // parse the patch using default settings for unified diff format } In the future we could replace the "true" with a preference or even invert the statement. [1] org.eclipse.compare.internal.core.patch.PatchReader
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.