Skip to content

Fix a merge at a branch tip losing a parent line in the graph - #17

Merged
VedangP57 merged 1 commit into
mainfrom
fix/graph-merge-tip
Oct 19, 2026
Merged

VedangP57 merged 1 commit into
mainfrom
fix/graph-merge-tip

Conversation

@VedangP57

Copy link
Copy Markdown
Owner

What

A merge commit at the tip of a branch (no child listed above it) could lose one of its two parent lines in the History graph. When no lane to its left was free, the second parent's line was given the merge's own column, the two lines lay on top of each other, and the next row dropped one of them. Any "Merge branch 'main' into feature" tip could hit it; in a real repo it drew the HEAD merge without its `─╮` and drew the heavy current-branch line thin.

The same flaw exists in upstream lazygit's `getNextPipes`, which the layout is ported from. The fix is one condition in `next_pipes`: an extra parent takes the first column that is not taken, not crossed by a continuing line, and not the commit's own column.

Tests

  • Exact-string tests for the reproduction, an octopus merge at a tip, and a case with a free lane to the left (unchanged by the fix).
  • The random-history property test now checks that every line going down either ends in the next commit or continues in the column it came in at, that no two lines share a column, and that each commit starts one line per parent. It runs on a new generator where many commits are tips with up to 4 parents. With the fix reverted, it fails; with the fix, it passes (also at 20,000 cases).
  • All ported lazygit tests still pass unchanged.
  • Checked read-only against a real repo: the merge tips now draw their second-parent lines and the heavy line stays heavy.

cargo test --workspace and clippy are clean.

A merge commit at a branch tip takes a new column on the right, which no
pipe ends in, so the search for its second parent's column could return
that same column: the two pipes overlapped and one was dropped on the next
row, and the parent turned up later as a tip of its own. lazygit's layout
has the same bug. The property test now checks that no pipe vanishes
between rows and that no two lines go down in one column.
@VedangP57
VedangP57 merged commit cf8a742 into main Oct 19, 2026
10 checks passed
@VedangP57
VedangP57 deleted the fix/graph-merge-tip branch October 19, 2026 21:06
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.

1 participant