Skip to content

Project checkout records no merge base for a new branch, so its diff is read against the default branch #5850

Closed

Description

@alexandre-vl

Summary

In a project checkout, a thread on a new branch made from dev (default branch main) shows the commits dev has beyond main as its own changes, and main as its merge branch. The environment records no merge base, so bb falls back to the default branch. Before #3227, the server recorded the new branch's base as the merge base.

Versions and environment

  • bb 0.46.1 (latest release). The host daemon runs on Debian 13 (Linux 6.12) with git 2.55.0.
  • Also reproduced from source at main e0f6fda, in the integration harness on macOS (Node 22.23.2). No commit has touched the code below since 0.46.1.
  • Project checkout environment provider, nothing else unusual.

Steps to reproduce

R=$(mktemp -d) && cd "$R"
git init -q --bare -b main origin.git
git init -q -b main seed
git -C seed commit -q --allow-empty -m "on main"
git -C seed push -q ../origin.git main
git -C seed switch -q -c dev
echo dev-only > seed/dev.txt && git -C seed add dev.txt && git -C seed commit -q -m "on dev only"
git -C seed push -q ../origin.git dev
git clone -q origin.git clone

bb thread spawn --project <any project on that machine> --host <machine> \
  --environment-provider project-checkout \
  --environment-inputs "{\"path\":\"$R/clone\",\"branch\":{\"kind\":\"new\",\"baseBranch\":\"origin/dev\"}}" \
  --prompt "Reply with exactly: OK. Run no command, read no file."
bb environment show <environment> --json

The same steps run as an integration test in the linked PR (tests/integration/fake/environments/project-checkout-branches.test.ts).

Expected vs actual

Actual: bb environment show --json reports "baseBranch": null, "defaultBranch": "main", "mergeBaseBranch": null, while the thread's branch sits on origin/dev:

71e57ea (HEAD -> bb/claude-repro-a-merge-base-to-archive-thr_bz52jkjmfy, origin/dev) on dev only
d9097ca (origin/main, origin/HEAD, main) on main

resolveEnvironmentMergeBaseBranch then picks main, and the diff lists a file the thread never touched. In that checkout:

$ git diff --name-only main...HEAD
dev.txt
$ git diff --name-only origin/dev...HEAD
$

The integration test, reading the diff through GET /environments/:id/diff as the app does, fails at e0f6fda with:

AssertionError: expected 'A\tdev.txt\n' to be '' // Object.is equality

Expected: mergeBaseBranch is the ref the branch was made from (origin/dev), so the untouched thread's diff is empty.

Evidence

What you ruled out

Suggested priority and effort

This hits every project-checkout thread on a new branch from a non-default base. The workaround is picking the merge base in the diff panel, or bb environment update <env> --merge-base-branch <base>. No work is lost. The fix is small, in the plugin only.

AGENT GENERATED

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority Medium · Effort Low. Applied labels: workspaces, confirmed-repro; no existing classification was replaced.
    • Report: https://get-bb.github.io/reports/issues/5850.html — REPRODUCED, high root-cause confidence. The same real-plugin/real-Git regression fails in two clean trusted-main checkouts.
    • Root cause: the successful checkout-provider result omits the selected new-branch base; core stores no merge base and falls back to the default branch, including inherited changes in the diff.
    • Fix: Preserve new checkout branch comparison bases #5856 — ready, unmerged; server-only metadata correction, regression, and documentation. 114 changed text lines across 3 files, with no protocol changes.
    • Verification: regression fails before and passes after; all 43 plugin tests and typecheck pass. git diff --check passes. No live user instance or linked PR code was run.
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