Skip to content

Fix UnifiedDiffReader to use correct DeltaType#228

Open
andrewparmet wants to merge 1 commit into
java-diff-utils:masterfrom
andrewparmet:fix/unified-diff-delta-types
Open

Fix UnifiedDiffReader to use correct DeltaType#228
andrewparmet wants to merge 1 commit into
java-diff-utils:masterfrom
andrewparmet:fix/unified-diff-delta-types

Conversation

@andrewparmet
Copy link
Copy Markdown

finalizeChunk() previously always created ChangeDelta regardless of whether the hunk contained only insertions, only deletions, or only context lines. This made it impossible for consumers to determine the actual type of change from the delta alone.

Now uses InsertDelta when a hunk contains only additions (no context), DeleteDelta when only deletions (no context), EqualDelta when only context, and ChangeDelta otherwise. Hunks with context lines still use ChangeDelta to preserve backward-compatible applyTo behavior.

Fixes #201.

finalizeChunk() previously always created ChangeDelta regardless of
whether the hunk contained only insertions, only deletions, or only
context lines. This made it impossible for consumers to determine the
actual type of change from the delta alone.

Now uses InsertDelta when a hunk contains only additions (no context),
DeleteDelta when only deletions (no context), EqualDelta when only
context, and ChangeDelta otherwise. Hunks with context lines still use
ChangeDelta to preserve backward-compatible applyTo behavior.

Fixes java-diff-utils#201
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

Successfully merging this pull request may close these issues.

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

2 participants