Skip to content

fix(pager): render conflicted Git diffs - #1102

Draft
0xferrous wants to merge 1 commit into
modem-dev:mainfrom
0xferrous:fix/git-combined-conflict-diff
Draft

fix(pager): render conflicted Git diffs#1102
0xferrous wants to merge 1 commit into
modem-dev:mainfrom
0xferrous:fix/git-combined-conflict-diff

Conversation

@0xferrous

@0xferrous 0xferrous commented Sep 12, 2026

Copy link
Copy Markdown

Summary

When Git is paused during a conflicted merge or rebase, git diff emits a combined diff using diff --cc/diff --combined headers and @@@ hunk syntax. With core.pager = "hunk pager", Hunk previously treated this input as an empty review:

No files match the current filter.

The pager/difftool configuration was valid; Hunk’s patch sanitizer did not support Git’s combined conflict format.

Fix

Normalize combined Git patches into the existing unified patch format before parsing:

  • Convert combined file and hunk headers to standard diff --git/@@ syntax.
  • Project the result against the first parent.
  • Omit lines deleted only from other parents.
  • Preserve conflict markers and partially resolved changes.
  • Handle binary combined conflicts with no unified hunk.
  • Handle --combined-all-paths by retaining the first parent’s path.
  • Leave ordinary unified patches unchanged.

This keeps the behavior in the shared patch-sanitization layer used by Hunk’s existing consumers.

Reproduction

  1. Configure Hunk as Git’s pager:

    git config --global core.pager "hunk pager"
  2. Start a conflicting merge or rebase.

  3. Run:

    git diff

Before this change, Hunk displayed an empty review. After this change, it displays the conflicted file and its conflict markers.

Validation

  • Focused parser and static pager tests: 42 passed
  • bun run typecheck
  • oxfmt --check
  • git diff --check
  • Pre-commit formatting and lint hooks passed
  • Manual real-PTY reproduction at 120×34 terminal dimensions
  • Added a patch Changeset for hunkdiff

Visual evidence was captured from the real Hunk TUI for the blank before state and rendered after state.

before:
image

after:
image

@vercel

vercel Bot commented Sep 12, 2026

Copy link
Copy Markdown

@0xferrous is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

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