gitui-org / gitui-org/gitui

Feature idea: diff a branch/worktree against a base branch (merge-base) via the compare view

オープン
#2,996 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
22.5k
フォーク
774
PR マージ指標
30日以内にマージされた PR はありません

説明

## Summary

Bind `v` to open the existing compare-commits view for a branch (or worktree) against a **base branch**, diffed from their **merge-base** (three-dot, `base...HEAD`) so it shows only that branch's own changes — a PR-style "what did this branch change" review. No new popup or tab: it reuses `CompareCommitsPopup` unchanged.

## Motivation

The Branches popup already has `Shift+C` ("Compare"), but that's a **tip-to-tip** (two-dot) diff of the selected branch vs `HEAD`, so it includes commits the base gained *after* the fork point (and reads in the opposite direction). A **merge-base** diff answers the "what has my branch changed relative to X" question directly, the way a PR diff reads.

## What it adds

One key, `v` (`diff_base`); the base varies by context, always merge-base:

- **Global `v`** — current branch (`HEAD`) vs the repo's base branch (auto-resolved: `main`/`master`/`origin/*`).
- **Branches popup `v`** ("Diff since branch-point") — current branch vs the *highlighted* branch (an arbitrary base). Sits next to the existing `Shift+C` ("Compare"); the distinct labels keep the two clear.
- **Worktrees popup `v`** — the selected worktree's branch vs the base branch, without switching into it.

Backend is a small `asyncgit` `branch_diff` module (`merge_base`, `resolve_base_branch`, `diff_range_vs_base`, `diff_range_vs_ref`). The triggers just resolve two commit ids and push the existing `OpenPopup(CompareCommits(...))`.

## Worktree touch-point (heads-up)

The **Worktrees-popup `v`** is built on a worktree-management popup that isn't upstream yet — proposed separately in #2995. So that surface can't land independently: a PR against current `master` would be **global `v` + Branches-popup `v`** only, with the worktree surface following if/after #2995 lands.

## Questions

1. Is this something you'd want as a PR?
2. If so, preferred scope — just the global "diff current branch vs main" `v`, or also the Branches-popup `v` (given the `Shift+C` overlap)?
3. Any preference on the key (`v`) or the command naming?

Working implementation on my fork if useful: https://github.com/stevenpollack/gitui/tree/feat/branch-diff

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず既存の Branches-popup の Shift+C トリガーと CompareCommitsPopup を読み、次に提案されている asyncgit の branch_diff モジュールとその merge-base ヘルパーを調べてください。未解決の質問から意図されたスコープを確定し、Worktrees-popup の UI を検討する前に #2995 を確認してください。完了とは、合意されたグローバル比較および/またはブランチ比較が、正しい merge-base 範囲で既存のビューを再利用することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, rust
領域
backend, cli
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。