java-diff-utils / java-diff-utils

Diff Utils library is an OpenSource library for performing the comparison / diff operations between texts or some kind of data: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future displaying (like side-by-side view) and so on.

Home Page:https://java-diff-utils.github.io/java-diff-utils/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnifiedDiff Separator Rule

elanzini opened this issue · comments

Describe the bug
I tried to parse this diff but I am getting an error. The problem seems to be with WARNING: >>> no rule matched Index: src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java that is separating the two patches. There is no rule that matches this separator. I am not sure whether this is standard format of separating patches and should be handled. If you think this case doesn't need to be handled, feel free to close the issue and I will work around it in my code.

To Reproduce
You can simply save the diff as diff.txt file and then parse it as follows:

FileInputStream stream = new FileInputStream(new File("/path/to/diff.txt"));
UnifiedDiff patch = UnifiedDiffReader.parseUnifiedDiff(stream);                      <-- ERROR

Expected behavior
I expected the UnifiedDiffReader to be able to parse the provided diff.

The new version fixes this problem. I was not aware, that each file could have a header section.