Skip to content

feature: add Compare with default base on current branch menu#2322

Open
ivnnv wants to merge 1 commit intosourcegit-scm:developfrom
ivnnv:pr/branch-diff
Open

feature: add Compare with default base on current branch menu#2322
ivnnv wants to merge 1 commit intosourcegit-scm:developfrom
ivnnv:pr/branch-diff

Conversation

@ivnnv
Copy link
Copy Markdown

@ivnnv ivnnv commented May 5, 2026

Other local branches in the sidebar already have a one-click "Compare with HEAD" entry, but the current branch's right-click only offers the free-form "Compare with..." palette. Adds a "Compare with <default>" entry that opens the existing Compare window pre-filled with the repo's default base branch.

Screenshot 2026-05-05 at 17 51 04

The default branch is resolved from refs/remotes/<remote>/HEAD (the same source GitHub/GitLab use), with the remote chosen via the same fallback order used elsewhere in the app: current branch's upstream remote → Settings.DefaultRemote → first remote. The entry is hidden when the remote HEAD is unset or when the resolved base equals the current branch (so it never shows "Compare master with master").

Test plan

  • Right-click the current branch and confirm "Compare with <default>" appears, opens the existing Compare window pre-filled.

Other local branches in the sidebar already have a one-click Compare
with HEAD entry, but the current branch's right-click only offers the
free-form Compare with... palette. Adds a Compare with <default> entry
that opens the existing Compare window pre-filled with the repo's
default base branch (resolved via refs/remotes/<remote>/HEAD).

The remote selection follows the same policy used elsewhere
(current branch's upstream remote -> Settings.DefaultRemote ->
first remote). The entry is hidden when the remote HEAD is unset
or when the resolved base equals the current branch.

Adds Commands/QueryDefaultBranch (one symbolic-ref call) and a
small resolver in BranchTree.axaml.cs. No changes to Compare,
CompareRevisions, or DiffOption.
love-linger added a commit that referenced this pull request May 6, 2026
…selected branch with its upstream directly (#2322)

Signed-off-by: leo <longshuang@msn.cn>
@love-linger
Copy link
Copy Markdown
Collaborator

Compare with HEAD is designed to allow quick comparison with the current branch (excluding uncommitted files - that's why we use HEAD instead of current branch name), and it has nothing to do with the default(main) branch.

I don't think SourceGit needs to integrate the feature of comparing with <remote>/HEAD:

  • When fallback to <remote>/HEAD, it means that the <remote>/HEAD is not the upstream of current branch. Therefore, I do not think we need to provide an individual context menu entry for this purpose. If users need it, they can select any branch to be compared from the Compare with... context menu entry.
  • User may confuse about that why non-current local branches have a context menu to compare with current branch's HEAD but the current local branch has a context menu to compare with remote's HEAD?

So, I pushed another commit that adds a quick context menu entry for all local branches to compare with its upstream

@love-linger love-linger self-assigned this May 7, 2026
@love-linger love-linger added the not-planned It's not planned in the future label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-planned It's not planned in the future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants