Re: [PATCH v9 0/4] graph: indent visual roots in graph
From: Mirko Faina <hidden>
Date: 2026-07-11 14:15:36
On Sat, Jul 11, 2026 at 03:37:49PM +0200, Pablo Sabater wrote:
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. GitHub CI: https://github.com/pabloosabaterr/git/actions/runs/29154333559 [1]: https://lore.kernel.org/git/xmqqwnwajbuj.fsf@gitster.c.googlers.com/ (local) V8 DIFF: - Checking if the parents of a commit are NULL is not enough to know if the commit is a visual root due to options that filter the commit parents but they do not remove them (--author, --grep, etc). At graph_is_visual_root_candidate(), iterate the parents and call graph_is_interesting() for each of them to know whether they will be shown or not. - Add a --author and a --grep test. Signed-off-by: Pablo Sabater <redacted> --- Pablo Sabater (4): lib-log-graph: move check_graph function revision: add next_commit_to_show() graph: add a 2 commit buffer for lookahead graph: indent visual root in graph graph.c | 295 +++++++++++++++++ graph.h | 17 + revision.c | 48 ++- t/lib-log-graph.sh | 5 + t/meson.build | 1 + t/t4215-log-skewed-merges.sh | 33 +- t/t4218-log-graph-indentation.sh | 514 +++++++++++++++++++++++++++++ t/t6016-rev-list-graph-simplify-history.sh | 25 +- 8 files changed, 893 insertions(+), 45 deletions(-)
Sorry, I know I'm a bit late to the discussion regarding the design, but, could we maybe have two different code paths for printing graphs? Having the old one as a default and this new one only when we're using --oneline (well, --format=reference would benefit too)? As it is now if I have multiple one-patch series in sequence the entries are unnecessarily indented. Thanks