$ 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.
*What is patch fuzz?* Patch fuzz is a situation when the patch tool ignores some of the context lines in order to apply the patch.
This means that one or more changes, called hunks, could not be introduced into the file. Occasionally this could be because the patch was emailed or copied into a file and whitespace was either added or removed. Try adding --ignore-whitespace to the command line to work around this.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With