[GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Apr 2, 2026, 21:17 UTC
- Message-ID
- <20260402211717.3604688-1-pabloosabaterr@gmail.com>
When having a history with multiple root commits and drawing the history near the roots, the graphing engine renders the commit one below the other, seeming that they are related, which makes the graph confusing.
This issue was reported by Junio at: https://lore.kernel.org/git/xmqqikaawrpx.fsf@gitster.g/
e.g.:
* root-B * child-A2 * child-A1 * root-A
This happens because the engine prints left to right from the first free column and the root has no parents thus for the next row, its column becomes free and the engine fills that gap with the next commit (child-A2) seeming that root-B and child-A2 are related when they are not.
The actual implementation is very minimal. This patch makes the roots to be kept alive at least one more row to avoid that and indent the next commit to the next column and then clean the mapping letting the indented commit to naturally collapse to the column where the root was.
e.g.:
* root-B
* child-A2
/
* child-A1
* root-AThis is done by adding a is_placeholder flag to the columns, the root commit is actually there but marked as a placeholder
e.g.:
* root-B
(B) * child-A2
/
* child-A1
* root-A(B) would be root-B column with the placeholder flag active.
Then teaching the rendering function to print a padding ' ' when meeting a placeholder column outputs the second example.
There could also be the case where there are multiple roots
without the patch:
* A root * B root * C root * D1 child * D root
with the patch, the indentation cascades:
* A root
* B root
* C root
* D1 child
_ /
/
/
* D rootthe _ / might look weird but that's how the collapsing rendering does it for big gaps, this case being from the 4th column to the 0th column. Another patch could change the collapsing rendering for placeholders ? I haven't done it to keep it minimal, but a follow up could make it to be straight '/'. This would make it bigger but easier for the eye to follow. IMO is not worth it, but opinions are welcome.
The patch also adds tests for different cases like a root preceding multiple parents merges and the examples above.
There could be some edge cases still so any testing is very welcome.
Pablo Sabater (1): graph: add indentation for commits preceded by a root
graph.c | 68 ++++++++++++++++-- t/t4215-log-skewed-merges.sh | 136 +++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+), 6 deletions(-)
base-commit: 256554692df0685b45e60778b08802b720880c50
-- 2.43.0