Repository navigation
Description
Proposal: preserve the primary branch spine in graph layout
Problem
When a feature branch contains commits newer than the tip of the primary branch (main or master), Serie assigns that feature branch to the leftmost graph column (column 0).
This makes the feature branch appear to be the primary trunk while the actual primary branch is rendered as a side branch. The graph remains topologically correct, but its visual hierarchy is misleading.
Minimal reproduction
git init -b master
git commit --allow-empty -m "001"
git commit --allow-empty -m "002"
git switch -c feature1
git commit --allow-empty -m "feat1"
git switch master
git commit --allow-empty -m "003"
git switch -c feature2
git commit --allow-empty -m "feat2"
git switch master
git merge --no-ff feature1 -m "merge feature1"
git switch feature2
git commit --allow-empty -m "feat2-2"
serieBecause feat2-2 is the newest commit under chronological ordering, it is processed first and receives column 0.
Current behavior
feature2 occupies the straight leftmost column, while the master commits bend into another column. This makes feature2 look like the primary trunk and master look like an offshoot.
Desired behavior
The first-parent spine of the repository's primary branch should remain in column 0, with feature branches rendered in subsequent columns. In this example, master should remain the leftmost vertical spine and feature2 should appear beside it.
Context & Prototype
To be completely upfront, I don't know anything about Rust. This visual quirk was only thing that regularly tripped me up, so I spent some time vibe coding to fix this problem.
I came up with a -m, --main-branch option that keeps the primary branch spine pinned to column 0:
-m, --main-branch <BRANCH> Primary branch to keep on the leftmost column [default: none] [possible values: auto, none, <branch-name>]
Because I didn't want to disrupt anyone's current setup or change Serie's existing conventions, I made it strictly opt-in (default: none), keeping the current behavior completely identical when omitted.
Rather than just dropping an unexpected PR out of the blue, I wanted to open this issue first to ask how you feel about the idea. If this sounds like something you'd be open to having in Serie, I would be more than happy to open a PR or tweak the approach to better fit your vision for the project.
Activity
lusingander commentedon Oct 2, 2026
Thanks for the detailed proposal! I agree that the current layout can make the visual hierarchy misleading in cases like the example, and I’m generally in favor of adding this feature.
I’d prefer to keep it explicit and opt-in, without the
autoandnonevalues:When the option is omitted, Serie should preserve its current behavior exactly.
The intended behavior would be to keep the first-parent spine of the specified branch in column 0. “Primary branch” here would therefore mean the branch selected by the user, rather than something Serie tries to detect automatically.
If the specified branch cannot be resolved, or if its tip is not included in the loaded commits because of
--max-count, Serie should print a warning and fall back to the normal graph layout instead of failing. If the tip is included but the older part of the spine is truncated by--max-count, pinning the visible part should be fine.One implementation detail to be aware of is that this probably needs to be incorporated into the lane-assignment step rather than applied to the calculated positions afterward. The current algorithm follows the leftmost first-parent child lane, so the primary spine commits will need to be identified beforehand and explicitly assigned to column 0.
Please also add a graph regression test for the successful primary-branch layout to
src/tests/graph.rs, along with the corresponding snapshots undertests/graph/. It would be good to cover bothchronoandtopoordering there. The warning and fallback cases do not need image snapshots and can be covered by focused unit tests where appropriate.With those points in mind, I’d be happy to review a PR for this. Thanks again for investigating it!