Skip to content

feat: add --base flag for branch comparison diffs - #1

Open
star-gusto wants to merge 1 commit into
Shugar:mainfrom
star-gusto:feat/base-ref-comparison
Open

feat: add --base flag for branch comparison diffs#1
star-gusto wants to merge 1 commit into
Shugar:mainfrom
star-gusto:feat/base-ref-comparison

Conversation

@star-gusto

@star-gusto star-gusto commented Apr 23, 2026

Copy link
Copy Markdown

What Is This Change

Adds a -b, --base <ref> CLI option that shows the diff between HEAD and a base ref (e.g. main, origin/main, a commit SHA) using git diff <base>...HEAD, rendered in Diffly's GitHub-like browser UI.

# compare current branch against main
diffly --base main

# compare against a specific commit
diffly --base abc1234

# combine with port flag
diffly -p 9393 --base origin/main

Without --base, behavior is unchanged -- Diffly shows working tree changes (staged, unstaged, untracked) as before.

Why Is This Change Being Made

Currently Diffly only shows uncommitted working tree changes. Once changes are committed, there's nothing to display. This makes Diffly less useful for the common workflow of reviewing a feature branch's full diff before opening a PR.

The --base flag fills that gap by letting users view committed branch diffs in Diffly's split-view UI -- the same way they'd see them on GitHub, but locally and instantly.

Tests

Tested manually against a real feature branch, affecting 9 files, in a large Rails monorepo:

  • diffly --base main correctly shows 9 changed files with full split-view diffs
  • /api/diff response includes base field identifying the ref
  • Without --base, existing behavior (working tree changes) is preserved
  • Invalid base ref produces a clear simple-git error message
  • Port flag (-p) works correctly alongside --base

References

Add `-b, --base <ref>` CLI option that compares HEAD against a base ref
(e.g. main, origin/main, a commit SHA) using `git diff <base>...HEAD`.

Without --base, behavior is unchanged (shows working tree changes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@star-gusto

Copy link
Copy Markdown
Author

@Shugar If you could take a look at this PR when you can, I'd appreciate 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