$ vim patch
Index: toPatch
===================================================================
--- toPatch
+++ toPatch
@@ -2,4 +2,4 @@
*/
-final public class XMLWriter {
+public class XMLWriter {
$ vim toPatch
*/
final public class XMLWriter {
public static float CURRENT_VERSION=2.2f;
$ patch -p0 -ui patch
patching file toPatch
Hunk #1 succeeded at 1 with fuzz 2 (offset -1 lines).
Why the fuzz and the line offset? This is a demo case trying to understand diff and patch, since tools sometimes/often don’t seem to work as expected.
Patch does some basic checking of consistency of the diff and your file, and if these checks fail, you get offset or fuzz.
You have offset -1, since patch expects the contents of the diff match lines 2–4 of your file. In your file, however, they are lines 1–3.
You have fuzz>0, since the first line of the context (two spaces and a
*/) does not match the line in the actual file (one space and a*/). Because of that, patch did a second pass where it ignored the first and the last line of the context.This doesn’t explain why you see fuzz=2 and not 1. Maybe an error copy-pasting the files? Any other ideas, anybody?