Skip to content

fix for inflated diff counts when base branch has been updated since stack init#39

Open
skarim wants to merge 1 commit intomainfrom
skarim/fix-view-diff
Open

fix for inflated diff counts when base branch has been updated since stack init#39
skarim wants to merge 1 commit intomainfrom
skarim/fix-view-diff

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented Apr 16, 2026

Fix inflated diff counts in gh stack view TUI

When the local base branch (e.g. main) had advanced past a branch's fork point, gh stack view showed inflated file counts and diff stats because the two-dot diff compared full trees instead of diffing from the fork point.

Fix: Always use git merge-base to find the fork point for diff computation, not just for merged branches.

Copilot AI review requested due to automatic review settings April 16, 2026 14:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect/inflated diff file counts in the stack view when the base branch has advanced since the stack was initialized by anchoring diffs to the merge-base (fork point) instead of the base branch tip.

Changes:

  • Update LoadBranchNodes to compute diff/commit ranges using git merge-base(base, branch) as the diff base.
  • Add unit tests covering diverged-base and linear-history scenarios to ensure merge-base is used.
Show a summary per file
File Description
internal/tui/stackview/data.go Switches diff anchor to merge-base to avoid including unrelated base-branch changes in file stats.
internal/tui/stackview/data_test.go Adds regression tests validating merge-base behavior for diverged and linear cases.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread internal/tui/stackview/data_test.go
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.

4 participants