You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Diff panel compares fork branches with origin/main when their base branch tracks upstream #38533
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
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.
Start a new worktree thread from main with Start from remote disabled, or create a branch from local main in any other way.
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.
Activity