Skip to content

Add option to show one-sided files as unified diffs - #73

Open
gnutix wants to merge 1 commit into
banga:mainfrom
gnutix:unify-one-sided-diffs
Open

gnutix wants to merge 1 commit into
banga:mainfrom
gnutix:unify-one-sided-diffs

Conversation

@gnutix

@gnutix gnutix commented Nov 7, 2026 •

Copy link
Copy Markdown

Closes #55.

A file with only additions, or only deletions, leaves one half of a split diff empty. This adds an opt-in setting that shows such files as unified diffs, while files with both additions and deletions stay split, like Refined GitHub does:

git config split-diffs.unify-one-sided-diffs true
  • Off by default, so nothing changes unless it is set.
  • Decided per file, not per hunk. A file whose first hunk only adds and second hunk only removes still counts as having both, so its layout doesn't switch between hunks.
  • Hunks are buffered per file when the setting is on, since one-sidedness is only known once the whole file has been read. With the setting off, output streams hunk by hunk as before.
  • Combined (merge) diffs are not affected, and the narrow-terminal fallback to unified still applies.

Tests

  • unifyOneSidedDiffs added to the snapshot config matrix, so every existing case also runs with the setting on.
  • A new case with an added-only, a mixed and a deleted-only file.
  • getGitConfig tests cover parsing the new key.
  • README documents the setting.

🤖 Generated with Claude Code Opus 5.5.

A file with only additions or only deletions leaves one half of a split
diff empty. The new `split-diffs.unify-one-sided-diffs` setting (off by
default) renders such files as unified diffs, while files with both
additions and deletions stay split, like Refined GitHub does.

The decision is made per file, so when the setting is on, a file's hunks
are buffered until the file ends.

Closes banga#55

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FPXTedgEC3D3TAaGpDdNe
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.

Feature request: smart unified diff

1 participant