Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support for fuzzy patches #112

Closed
@dpoetzsch

Description

@dpoetzsch

When generating a unified diff with context, I would like to be able to do a fuzzy apply of that patch. Does your library support this?

For example, take the following unified diff with context 3:

--- original
+++ modified
@@ -2,6 +2,9 @@
 2
 3
 4
+a
+b
+c
 5
 6
 7

And my file looks like the following (exactly the original but with three lines added to the top):

x
y
z
1
2
3
4
5
6
7
8

Using the linux patch tool I am still able to apply this patch:

$ patch -o - neworig udiff.patch
patching file - (read from neworig)
Hunk #1 succeeded at 5 with fuzz 1 (offset 3 lines).

When using DiffUtils.patch of your library I get an error (because the line numbers no longer match):

Incorrect Chunk: the chunk content doesn't match the target

Maybe there is a configuration option to enable fuzzy patching?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions