Diff branch changes from the merge base, like a pull request - #88
Merged
Conversation
getMergeBase finds the last commit two branches agreed on (null for unrelated histories), exposed to the renderer as gitgrove.mergeBase. The branch-changes view needs it: diffing a branch from its fork point over-counts once the branch merged its upstream back in, while mergeBase..tip is exactly the branch's own work — what its PR shows.
GraphRow.upstreamHash names the tip of the branch this one grew from — or, when the branch's tip was already merged away, that target just before the landing merge, the way a pull request keeps comparing after it lands. Only a merge ON the fork parent's chain counts as landing, so a sync merge that pulled main into a child branch never turns the child into main's upstream. mergeChildOf becomes mergeChildrenOf (newest first) to make that distinction possible.
Clicking a branch label diffed forkPoint..tip, so a branch that had merged its upstream back in counted everything the upstream did in between as its own changes (ai-extra-features showed 42 files where PR #75 shows 23). openRange now refines the base to merge-base(upstream, tip) before loading files, keeping the pane header, file list and per-file diffs on the same base; branches with no known upstream (the mainline, root chains) keep the old behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clicking a branch label in the Graph tab diffs
forkPoint..tip— the fork point being the first parent of the branch's oldest commit. Once a branch merges its upstream back in (the update-merge a long-lived branch does to stay current), that range also contains everything the upstream did in between, and the pane counts it as the branch's own work.Concrete case:
ai-extra-featuresshows 42 files (+4110 −46), while its PR (#75) shows 23 files (+1447 −96). GitHub diffs frommerge-base(main, tip)— the last commit both sides agreed on — so the mainline work the branch merged in is excluded.Fix
getMergeBase(git read layer) +mergeBaseacross the IPC spine: the merge base of two commits, null for unrelated histories.GraphRow.upstreamHash(pure layout): the tip of the branch this one grew from — or, when the tip was already merged away, that target just before the landing merge, the way a PR keeps comparing after it lands. Only a merge on the fork parent's chain counts as landing, so a sync merge pulling main into a child never turns the child into main's upstream.openRangeresolves the base tomerge-base(upstream, tip)before loading files, so the pane header, the file list, and every per-file diff share the same base. Branches with no known upstream (the mainline, root chains, empty branches) keep the old behavior.Verification
git diff 3e0956b..7a561eb(the resolved base) = 23 files, +1447 −96 — byte-identical to PR Add opt-in AI features: commit messages, explanations, branch names, error help #75's stats.ai-extra-featuresnow shows 23 files / +1447 −96 with base3e0956b; clickingmainis unchanged; zero console errors.getMergeBase(agreement point, own-work-only range, unrelated histories) and layout tests forupstreamHash(unmerged, merged, and the sync-merge guard).lint,typecheck, andtestall green (842 pass).🤖 Generated with Claude Code