Skip to content

Backport pr156 fixes#166

Merged
twaugh merged 7 commits into0.4.xfrom
backport-pr156-fixes
Feb 25, 2026
Merged

Backport pr156 fixes#166
twaugh merged 7 commits into0.4.xfrom
backport-pr156-fixes

Conversation

@twaugh
Copy link
Owner

@twaugh twaugh commented Feb 25, 2026

Add in some bug fixes from #156 along with test cases.

twaugh and others added 6 commits February 25, 2026 12:44
Test case for issue where interdiff incorrectly reports 'patch2 is empty'
when the @@ line isn't immediately after the +++ line (e.g., when there's
an 'index' line in between).

This test currently fails on 0.4.x and will pass after applying the fix
from commit 3a6e39d.

Assisted-by: Claude Code
When an @@ line isn't immediately after the +++ line in patch2, the next
line is checked from the top of the loop which tries to search for a +++
line again, even though the +++ was already found. This results in the +++
not being found again and thus a spurious error that patch2 is empty.

Fix this by making the patch2 case loop over the next line until either an
@@ is found or the patch is exhausted.
Test case for issue where interdiff incorrectly warns that patches don't
contain a patch when they only have mode changes, binary diffs, or merge
metadata without actual unified diff content.

This test currently fails on 0.4.x and will pass after applying the fix
from commit edded43.

Assisted-by: Claude Code
Patches that contain only mode changes, binary diffs, merge metadata, or no
diff content at all would trigger a spurious error message. Check for
actual file-header '--- a/' or '--- /dev/null' lines before reporting a
patch as invalid.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Coloring the newline character results in the terminal cursor becoming
colored when the final line in the interdiff is colored.

Fix this by not coloring the newline character.
When a '---' header is parsed but the following line is not '+++' or hits
EOF, the allocated filename from the '---' line is leaked. Free it on both
early-exit paths, matching the pattern already used in
index_patch_generic().

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@twaugh twaugh force-pushed the backport-pr156-fixes branch from 408fed4 to 87e0099 Compare February 25, 2026 12:45
Add the two new test cases to the TESTS variable:
- tests/interdiff-patch2-headers/run-test
- tests/interdiff-mode-only/run-test

Assisted-by: Claude Code
@twaugh twaugh force-pushed the backport-pr156-fixes branch from 87e0099 to 548613e Compare February 25, 2026 12:46
@twaugh twaugh merged commit 9f5678c into 0.4.x Feb 25, 2026
5 checks passed
@twaugh twaugh deleted the backport-pr156-fixes branch February 25, 2026 13:07
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.

2 participants