← 输入框|github.com|刷新
Skip to content

Preserve header-only Git file boundaries in UnifiedDiffReader - #240

Merged
wumpz merged 1 commit into
java-diff-utils:masterfrom
JimmyLiuJia:fix/header-only-file-boundaries
Oct 10, 2026
Merged

wumpz merged 1 commit into
java-diff-utils:masterfrom
JimmyLiuJia:fix/header-only-file-boundaries

Conversation

@JimmyLiuJia

Copy link
Copy Markdown
Contributor

UnifiedDiffReader merges consecutive Git file sections when the preceding file has no text hunk. A patch generated by Git containing a binary edit, an empty-file addition, a mode-only change, a 100% rename, and a text edit currently returns one file instead of five; the final text file also inherits the preceding files' metadata.

Start a fresh file when another diff command is encountered within the same header section. Regression tests cover header-only files before a text hunk, consecutive header-only files at EOF, and a text hunk followed by mode-only and binary changes. They check file counts, metadata isolation, and application of the text patch.

Validation on Temurin 17.0.20.1:

  • Replayed the Git-generated five-file patch: one file before the fix, five independent files afterward.
  • The first two regression tests fail on the original implementation and pass with the fix.
  • mvn -B package passes across both modules: 170 tests, no failures or errors, 3 existing skipped tests. Checkstyle reports no violations.

AI assistance was used to implement the fix and regression tests; the verification above was run locally.

@wumpz
wumpz merged commit 9a76f4d into java-diff-utils:master Oct 10, 2026
4 checks passed
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