Skip to content

feat(branch): compare two branches without checking either out - #35

Merged
imfing merged 1 commit into
mainfrom
worktree-branch-head-arg
Oct 6, 2026
Merged

imfing merged 1 commit into
mainfrom
worktree-branch-head-arg

Conversation

@imfing

@imfing imfing commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • diffs branch BASE HEAD reviews HEAD against BASE (same as git diff BASE...HEAD) without either branch being checked out; omitting HEAD keeps today's behavior
  • git::branch_diff takes an optional head ref; --include-dirty conflicts with it (clap) and is a 400 from /api/branch-diff, since uncommitted changes only make sense for the checked-out branch
  • An unknown head ref fails fast in the CLI (unknown head ref: <name>)
  • /api/blob accepts rev=<ref> with path, so pure renames (no blob oids) load from the reviewed branch instead of the working tree
  • Local comments accept an optional ?branch= scope, so threads on a non-checked-out branch are filed under it; diffs comments is unchanged (None scope)
  • Web forwards ?head=, shows it in the title/branch chip/export, and keeps it when switching base

Much of the comments.rs diff is cargo fmt re-wrapping existing call sites that now take a scope argument.

Test plan

  • cargo test, cargo clippy --all-targets -D warnings, cargo fmt
  • tsc, oxlint, oxfmt, vite build
  • New tests: parity of branch_diff(main, Some(feature)) vs git diff main...feature with a third dirty branch checked out; DirtyWithHead error; read_rev_file; explicit comment scope; comment scope query validation; CLI target/label encoding
  • End-to-end smoke test on a scratch repo (checked out on a dirty third branch): served diff contains only feature's edit + rename, renamed file loads from feature, head+dirty returns 400, comment filed under feature

`diffs branch BASE HEAD` reviews HEAD against BASE (like `git diff
BASE...HEAD`) without HEAD being the checked-out branch.

- git::branch_diff takes an optional head ref; --include-dirty conflicts
  with it (CLI) and is a 400 from /api/branch-diff.
- /api/blob accepts rev=<ref> with path, so pure renames load from the
  reviewed branch instead of the working tree.
- Local comments accept an optional branch scope (?branch=), so threads
  on a non-checked-out branch are filed under it.
- Web forwards ?head= and keeps it when switching base.
@imfing
imfing marked this pull request as ready for review October 6, 2026 21:23
@imfing
imfing merged commit bbee957 into main Oct 6, 2026
8 checks passed
@imfing imfing mentioned this pull request Oct 6, 2026
2 tasks done
@imfing
imfing deleted the worktree-branch-head-arg branch October 6, 2026 22:04
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