Skip to content

[Bug]: Diff panel compares fork branches with origin/main when their base branch tracks upstream #38533

Closed

Description

@Turbo87

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Not sure

Steps to reproduce

  1. Use a fork checkout: origin is <you>/<repo>, upstream is <org>/<repo>, and local main tracks upstream/main. Let the fork's main fall behind upstream/main.
  2. Start a new worktree thread from main with Start from remote disabled, or create a branch from local main in any other way.
  3. Commit something on the new branch and open the Diff panel with the automatic base.

Expected behavior

The automatic base is upstream/main, the ref that the recorded base branch main tracks. The panel shows only the branch's own commits.

Actual behavior

The automatic base is origin/main. The panel also shows every commit that upstream/main gained since the fork was last synced.

The worktree records branch.<b>.t3-merge-base = main and no t3-merge-base-ref. resolveBaseBranchForNoUpstream() only uses the configured base directly if it contains a /. Otherwise it qualifies the plain name with findPrimaryRemoteName(), which returns origin whenever an origin remote exists. The tracking config of local main (branch.main.remote = upstream) is never consulted. Branches without any recorded base reach the same origin qualification through the default-branch fallback.

Worktrees started with Start from remote are not affected since #21032, because they record t3-merge-base-ref = refs/remotes/upstream/main. #21032 says locally started worktrees "retain the normal remote comparison", and in a fork checkout that comparison is the fork.

A possible fix is to resolve a plain configured base the same way resolveWorktreeBaseRemote() already does: when refs/heads/<base> exists and tracks a remote branch, compare against that tracking ref (<base>@{upstream}), and only fall back to the primary remote when it has none. #17314 describes the broader split between base and push remotes.

Impact

Minor bug or occasional failure

Version or commit

v0.1.10

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions