[PATCH v7 0/3] graph: indent visual roots in graph
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jul 4, 2026, 08:52 UTC
- Message-ID
- <20260704-ps-pre-commit-indent-v7-0-a94706cc8376@gmail.com>
- In-Reply-To
- <20260620-ps-pre-commit-indent-v6-0-cdc6d8fd5fbc@gmail.com>
When rendering a graph, if the history contains multiple "visual roots", actual roots or commits that look like roots (i.e. have their parents filtered out) can end up being vertically adjacent to unrelated commits, falsely appearing to be related.
A fix for this issue was already attempted [1] a while ago.
This series adds indentation to the visual root commits, so they cannot be vertically adjacent anymore making it easier to identify them.
Before indentation:
* A * B1 * B2 * C1 * C2
After indentation:
* A * B1 \ * B2 * C1 * C2
Indents the visual root commits that have still commits to show after them, and if they have children it connects them with an edge at a new row.
If there are multiple visual roots adjacent in history, the indentation starts with the second one, avoiding redundant indentation of the first one and cascades after the second.
* A * B * C * D1 * D2
This series first commit is a cleanup that brings a common function from t4215 and t6016 to a graph functions file which they both use, so the new test file for indentation, t4218, can use it as well.
[1]: https://lore.kernel.org/git/xmqqwnwajbuj.fsf@gitster.c.googlers.com/
V6 DIFF:
- Replaced the queue peeking with a 2-entry lookahead buffer populated by get_revision_internal() (second commit and graph_peek_next_visible()).
- Changed assert() with BUG() at graph_output_pre_root_line().
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
---
Pablo Sabater (3):
lib-log-graph: move check_graph function
graph: add a 2 commit buffer for lookahead
graph: indent visual root in graphgraph.c | 282 ++++++++++++++++++ graph.h | 17 ++ revision.c | 17 +- t/lib-log-graph.sh | 5 + t/meson.build | 1 + t/t4215-log-skewed-merges.sh | 33 +-- t/t4218-log-graph-indentation.sh | 453 +++++++++++++++++++++++++++++ t/t6016-rev-list-graph-simplify-history.sh | 25 +- 8 files changed, 798 insertions(+), 35 deletions(-) --- base-commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc change-id: 20260612-ps-pre-commit-indent-39ca72816382
Best regards, -- Pablo Sabater <pabloosabaterr@gmail.com>