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

Question: Is there a way to generate back raw Unified Diff from UnifiedDiff object?

challarao opened this issue · comments

I'm experimenting this library for one of my use cases. I have a git patch that I parse with #parseUnifiedDiff. Is there a way to get raw unified diff back from UnifiedDiff object? I see there is a generateUnifiedDiff method that requires original lines.

My requirement is to try and get raw Unified Diff for each individual file from git patch. I can of course use the metadata from UnifiedDiff object and and hand code it myself. Just wondering if there is an existing way out of the lib.

This can be rephrased as splitting per file Unified Diff out of git patch.

I am not quite sure if I understand you right. Isn't UnifiedDiffWriterl.write what you want? However, you are using the new implementation of this unified diff processing and the writer is not yet complete, so if you have problems lets improve it.