Skip to content

fix(step): diff against the target's upstream when the local target is stale - #4281

Merged
max-sixty merged 2 commits into
mainfrom
step-diff-stale-target
Sep 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
step-diff-stale-target

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

wt step diff diffed from merge-base(HEAD, target). When a branch is built on origin/main and local main lags it, that merge base is local main itself, so the diff counted every upstream commit the branch sits on as the branch's own. In the case that surfaced this, a one-commit branch 9 commits ahead of a stale local main showed 39 files instead of its 3.

#3549 fixed this topology for wt merge, wt step squash and wt step rebase via span_upstream, but wt step diff was left out, even though its help says it shows "what wt merge would include". It now uses the same rule, so its diff matches what wt merge would squash and what the wt list columns and picker diff pane already measure against. Explicit targets with no upstream (origin/main, a SHA) are unchanged.

The new test sits with the other #3519 tests in merge.rs and reuses their stale-main fixture. With the fix reverted, it fails and lists the upstream commits' files.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits September 26, 2026 10:12
…s stale

`wt step diff` diffed from merge-base(HEAD, target). When a branch is built on
origin/main and local main lags it, that merge base is local main itself, so the
diff counted every upstream commit the branch sits on as the branch's own.

`wt merge`, `wt step squash`, and `wt step rebase` already measure against the
upstream in this topology (#3549, via `span_upstream`); `wt step diff`, whose
help promises "what `wt merge` would include", now does too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit dacc21a into main Sep 26, 2026
38 checks passed
@max-sixty
max-sixty deleted the step-diff-stale-target branch September 26, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants