[PATCH v10 0/7] graph: indent visual roots in graph
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jul 13, 2026, 10:44 UTC
- Message-ID
- <20260713-ps-pre-commit-indent-v10-0-82ddab26bc96@gmail.com>
- In-Reply-To
- <20260711-ps-pre-commit-indent-v9-0-eab6676e82f7@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 * D * E * F * G * H * I * J1 * J2
The indentation wraps after cascading columns and when wrapping back to the initial column if the next commit is a non-visual-root commit, force the indentation one extra level.
Series explanation:
- Cleanup to bring a common function from t4215 and t6016 that will be used in t4218.
- Logic extraction of the chose of from where the commit source comes from.
- Add a buffer for lookahead purposes.
- Principal commit. Implement the logic to get the visual roots indented.
- Make visual root cascading wrap after 4 columns
- Add --[no-]graph-indent and log.graphIndent options.
GitHub CI: https://github.com/pabloosabaterr/git/actions/runs/29241054418
[1]: https://lore.kernel.org/git/xmqqwnwajbuj.fsf@gitster.c.googlers.com/
V9 DIFF:
- visual roots cascading now wrap after 4 columns. This was introduced into a new commit to make reviewing easier because the Main one is already big and has gone through multiple rounds already.
- Made a new graph_read_config() function where the calls to repo_config_get_*() live to leave graph_init() simpler.
- Added --[no-]graph-indent and log.graphIndent options so a user can set his preferences about the graph indentation.
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
---
Pablo Sabater (7):
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: wrap cascading commits after 4 columns
graph: move config reading into graph_read_config()
graph: add --[no-]graph-indent and log.graphIndentDocumentation/config/log.adoc | 4 + Documentation/rev-list-options.adoc | 8 + graph.c | 332 +++++++++++++++- graph.h | 17 + revision.c | 57 ++- revision.h | 2 + t/lib-log-graph.sh | 5 + t/meson.build | 1 + t/t4215-log-skewed-merges.sh | 33 +- t/t4218-log-graph-indentation.sh | 595 +++++++++++++++++++++++++++++ t/t6016-rev-list-graph-simplify-history.sh | 25 +- 11 files changed, 1031 insertions(+), 48 deletions(-)
Range-diff versus v9:
1: 22ab444372 = 1: 9541b410b7 lib-log-graph: move check_graph function 2: ebb88c8b29 = 2: 4f8fb2cc1d revision: add next_commit_to_show() 3: 0705ee321e = 3: b50574bbe1 graph: add a 2 commit buffer for lookahead 4: fa2e60fb3f = 4: fc3a8253fd graph: indent visual root in graph -: ---------- > 5: 204aae5061 graph: wrap cascading commits after 4 columns -: ---------- > 6: 1b42ed86a1 graph: move config reading into graph_read_config() -: ---------- > 7: 737331b68d graph: add --[no-]graph-indent and log.graphIndent
--- base-commit: f60db8d575adb79761d363e026fb49bddf330c73