Skip to content

merge: add an option to select how incomplete hunks are rendered - #88

Merged
bmwill merged 1 commit into
masterfrom
merge-hunk-style
Aug 31, 2026
Merged

merge: add an option to select how incomplete hunks are rendered#88
bmwill merged 1 commit into
masterfrom
merge-hunk-style

Conversation

@bmwill

@bmwill bmwill commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Commit 31de940 (merge: keep conflict markers on their own lines, #85) changed how conflict markers are rendered when a conflicting hunk ends in an incomplete line (one without a trailing newline), inserting a newline so that every marker starts at the beginning of a line. That matched the behavior of git merge-file, but silently diverged from GNU diff3 -m, which the diffutils manual documents as appending the succeeding markers directly to the incomplete line.

With this commit, the behavior is now selectable via a new two-variant enum, IncompleteHunkStyle, on MergeOptions:

Also add a table-driven test covering all eight permutations of the three inputs having or lacking a trailing newline, for both styles and for both the str and bytes paths. The expected outputs were verified against GNU diff3 3.12 and git 2.55.0: git produces byte-identical output for every permutation, while GNU diff3 glues each side's succeeding marker independently.

Commit 31de940 (merge: keep conflict markers on their own lines, #85)
changed how conflict markers are rendered when a conflicting hunk ends in
an incomplete line (one without a trailing newline), inserting a newline
so that every marker starts at the beginning of a line. That matched the
behavior of `git merge-file`, but silently diverged from GNU `diff3 -m`,
which the diffutils manual documents as appending the succeeding markers
directly to the incomplete line.

With this commit, the behavior is now selectable via a new two-variant
enum, `IncompleteHunkStyle`, on `MergeOptions`:

* `Diff3` (the default) appends markers directly to the incomplete line,
  matching GNU `diff3 -m` and restoring the pre-#85 output.
* `Git` inserts a newline after the incomplete line, matching
  `git merge-file`.

Also add a table-driven test covering all eight permutations of the
three inputs having or lacking a trailing newline, for both styles and
for both the str and bytes paths. The expected outputs were verified
against GNU diff3 3.12 and git 2.55.0: git produces byte-identical
output for every permutation, while GNU diff3 glues each side's
succeeding marker independently.
@bmwill
bmwill merged commit e5cc468 into master Aug 31, 2026
46 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.

1 participant