Skip to content

Diff tab prefers stale local base over origin branch #7114

Closed

Description

@d1mka112

Summary

The Diff tab can include unrelated changes when the local base branch trails its remote tracking branch. For a short base name such as develop, the Git plugin resolves the local branch first, even when origin/develop is present and newer.

Versions and environment

bb 0.48.1 desktop app on macOS; Git worktree environment with a clean feature branch. Reproduced against source fa30b0a with a synthetic repository in the Git plugin test suite.

Steps to reproduce

  1. Create a repository with main at commit A.
  2. Commit an unrelated base.txt on main (commit B), and set refs/remotes/origin/main to B.
  3. Create feature from B, move the unused local main ref back to A, and commit feature.txt on feature.
  4. Run bb git diff <environment-id> --target branch_committed --merge-base-branch main --json.

The executable fixture is in the proposed workspace-reads.test.ts change.

Expected vs actual

Expected: one changed file, feature.txt, matching origin/main...feature.

Actual on 0.48.1: two changed files, base.txt and feature.txt, matching stale local main...feature. In the observed worktree this inflated the Diff tab from 24 files and 1,876 additions to 224 files and 5,027 additions plus 1,044 deletions. The working tree was clean. Choosing origin/develop explicitly returned the expected 24 files.

Evidence

resolveMergeBaseBranch at fa30b0a checks the short local ref before refs/remotes/origin/<branch>.

What I ruled out

Suggested priority and effort

Medium: the diff can mislead code review; selecting origin/<branch> explicitly is a workaround.

AGENT GENERATED

Activity

  1. added theissue type on Nov 5, 2026
  2. added
    workspaces
    confirmed-repro
    on Nov 5, 2026
  3. bb-slop-cop commented on Nov 5, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Applied missing classifications: Bug · Medium priority · Low effort; labels: workspaces, confirmed-repro. Final Type re-read: Bug.
    • Reproduction and root-cause report: REPRODUCED, high root-cause confidence.
    • Root cause: short-base resolution returns the older local ref before considering the available origin tracking ref, including upstream-only commits in the comparison.
    • A newly authored regression fails on unchanged origin/main (fa30b0a) in two clean checkouts: short base lists two files; explicit remote lists one; worktree is clean. Existing Git plugin coverage passes: 35 files, 276 tests.
    • No PR: local-first precedence is explicitly documented, tested, and intentional in source history; changing that policy needs a product decision, outside the safe simple-fix conditions. Explicit origin/<branch> is a verified workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions