feat: allow :Greview to review explicit base/head refs #213

Closed
opened 2026-04-19 23:33:38 +00:00 by barrettruth · 0 comments
barrettruth commented 2026-04-19 23:33:38 +00:00

Prerequisites

  • I have searched existing issues

Problem

:Greview [base] is currently anchored to the state of the repository/worktree at repo_root, not to an explicit review pair.

The docs describe it as reviewing the repository against [base], and the current implementation of require('diffs.commands').greview(base, opts) shells out to:

git -C <repo_root> diff --no-ext-diff --no-color <base>

That means it can review:

  • the current worktree/index vs a base ref
  • or a different checkout/worktree when repo_root points somewhere else

But it cannot directly review an arbitrary PR/ref pair like:

  • origin/main...refs/forge/pr/42
  • base=<base>, head=<head>

without first materializing the head in a checkout/worktree.

This makes integrations with PR-oriented tools awkward, because tools like Forge can already resolve a PR to explicit base/head refs and would ideally open Greview without mutating the user workspace.

Proposed solution

Add a way for Greview / greview() to accept an explicit head ref in addition to the base.

A few possible shapes:

Ex command

:Greview <base>...<head>

or

:Greview <base> <head>

Lua API

require('diffs.commands').greview({ base = 'origin/main', head = 'refs/forge/pr/42' })

or a backward-compatible extension like:

require('diffs.commands').greview('origin/main', {
  head = 'refs/forge/pr/42',
  repo_root = '/path/to/repo',
})

Semantically, I think the best default for PR review is merge-base behavior (base...head), but even a raw explicit two-ref comparison would unlock the integration.

This would let diffs.nvim act as a true non-checkout PR review surface, similar to how users can open :DiffviewOpen origin/main...HEAD or :CodeDiff origin/main...HEAD in other plugins.

Alternatives considered

  • Hidden temp worktree + existing greview(base, { repo_root = temp_root })

    • technically works, but it still requires materializing the head ref in another checkout/worktree
    • feels heavier than necessary when the refs are already known
  • Keeping Greview strictly worktree-anchored

    • simpler, but it limits Forge/PR-style integrations to checkout-backed flows
## Prerequisites - [x] I have searched existing issues ## Problem `:Greview [base]` is currently anchored to the state of the repository/worktree at `repo_root`, not to an explicit review pair. The docs describe it as reviewing the repository against `[base]`, and the current implementation of `require('diffs.commands').greview(base, opts)` shells out to: ```sh git -C <repo_root> diff --no-ext-diff --no-color <base> ``` That means it can review: - the current worktree/index vs a base ref - or a different checkout/worktree when `repo_root` points somewhere else But it cannot directly review an arbitrary PR/ref pair like: - `origin/main...refs/forge/pr/42` - `base=<base>, head=<head>` without first materializing the head in a checkout/worktree. This makes integrations with PR-oriented tools awkward, because tools like Forge can already resolve a PR to explicit base/head refs and would ideally open `Greview` without mutating the user workspace. ## Proposed solution Add a way for `Greview` / `greview()` to accept an explicit head ref in addition to the base. A few possible shapes: ### Ex command ```vim :Greview <base>...<head> ``` or ```vim :Greview <base> <head> ``` ### Lua API ```lua require('diffs.commands').greview({ base = 'origin/main', head = 'refs/forge/pr/42' }) ``` or a backward-compatible extension like: ```lua require('diffs.commands').greview('origin/main', { head = 'refs/forge/pr/42', repo_root = '/path/to/repo', }) ``` Semantically, I think the best default for PR review is merge-base behavior (`base...head`), but even a raw explicit two-ref comparison would unlock the integration. This would let `diffs.nvim` act as a true non-checkout PR review surface, similar to how users can open `:DiffviewOpen origin/main...HEAD` or `:CodeDiff origin/main...HEAD` in other plugins. ## Alternatives considered - Hidden temp worktree + existing `greview(base, { repo_root = temp_root })` - technically works, but it still requires materializing the head ref in another checkout/worktree - feels heavier than necessary when the refs are already known - Keeping `Greview` strictly worktree-anchored - simpler, but it limits Forge/PR-style integrations to checkout-backed flows
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/diffs.nvim#213
No description provided.