Skip to content

DeltaType always assigned as CHANGE in UnifiedDiff.parseUnifiedDiff(InputStream stream) #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MadnessIRL opened this issue Mar 5, 2025 · 1 comment

Comments

@MadnessIRL
Copy link

Good day everyone,

I am trying to wrap my head around the library, and this might be more of a question rather than a bug(?)...

When parsing unidiffs in this format:
https://github.com/java-diff-utils/java-diff-utils/blob/01a7fb16cfc33abc3e6ac4adcc2db79438f56fcf/java-diff-utils/src/test/resources/com/github/difflib/unifieddiff/jsqlparser_patch_1.diff

line 19 will be raised as change rather than insert:

Image

The object created by parseUnifiedDiff() allows me to re-parse with DiffUtils.diff(delta.getSourceLines, delta.getTargetLines) to obtain the correct DeltaType (in this case INSERT, not CHANGE) but it obviously loses the line numbering (position):

  • original delta obtained by parseUnifiedDiff().getFiles().get(0).getPatch().getDeltas() -
    Image

  • re-parsed with DiffUtils.diff() -
    Image

Perhaps I am doing something wrong... but instinctively, shouldn't parseUnifiedDiff already assign the correct DeltaType?

@wumpz
Copy link
Collaborator

wumpz commented May 4, 2025

You are right, that finalizeChunk only creates Change instances. This works, but you are right, that the right type should be put in there. PRs are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants