Skip to content

Add UI branch comparison - #1527

Open
MUFFANUJ wants to merge 2 commits into
jupyterlab:mainfrom
MUFFANUJ:diff-branches-ui
Open

MUFFANUJ wants to merge 2 commits into
jupyterlab:mainfrom
MUFFANUJ:diff-branches-ui

Conversation

@MUFFANUJ

Copy link
Copy Markdown
Member

Closes #1512

This PR adds a UI action to compare any non-current branch against the current branch from the Branches and Tags section. It addresses #1512 by letting users inspect all changes between, for example, main and a feature branch without checking each commit individually.

The implementation reuses the existing diff API, which already accepts Git refs. CommitComparisonBox now works with generic Git refs instead of commit-only objects, branch rows expose a “Compare with current branch” diff action, and GitPanel renders the resulting changed-file summary below the branch list. Existing commit comparison behaviour is preserved by converting commits into the same ref-based shape.

Tests were added and updated for the branch compare button, GitPanel branch comparison flow, and generic ref diff handling in CommitComparisonBox.

@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a Binder on branch MUFFANUJ/jupyterlab-git/diff-branches-ui

@MUFFANUJ MUFFANUJ self-assigned this Aug 23, 2026
@MUFFANUJ

Copy link
Copy Markdown
Member Author

While implementing branch comparison, I noticed a separate case in the existing backend diff parsing.

The new UI reuses the existing model.diff(base, target) path, which already supports Git refs such as commits and branches. That part works for normal branch diffs.

However, the backend parser in packages/core/jupyterlab_git_core/git.py currently parses git diff --numstat -z output by splitting each entry on whitespace. That can misread filenames that contain spaces, and it may also mishandle renamed files because Git emits extra path information for renames.

This is not caused by the branch-comparison UI change, but the new feature may make the existing parser limitation easier to hit when comparing whole branches.

Would you prefer that I keep this PR scoped to exposing branch comparison in the UI, or should I also include a backend parser fix for paths with spaces / renamed files here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to diff branches

1 participant