Subject: Re: [GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root

From: Junio C Hamano <[email-masked]>
Date: Thu, 02 Apr 2026 22:04:32 -0700

Pablo Sabater <[email-masked]> writes:

> This issue was reported by Junio at:
>   https://lore.kernel.org/git/[email-masked]/

You are giving me too much credit.  I just knew about previous
attempts and the gotchas.

One thing that we may want to make sure your solution gets right is
the issue depicated in two graphs in the footnote of this message:

  https://lore.kernel.org/git/[email-masked]/

    Stepping back a bit, I think concentrating too much on "is it
    root?" is a wrong way to think about the problem.  Suppose you
    have two histories, e.g. (time flows from left to right; A and X
    are roots)

            A---B
                 \
          X---Y---Z

    and doing "git log --graph --oneline Z" would show A, B, X, Y
    and Z.

    But in a slightly modified graph:

          C
         /
        O---A---B
                 \
          X---Y---Z

    if you do "git log --graph --oneline C..Z", you should see the
    same commits listed as above (A, B, X, Y and Z), and most likely
    in the same order.

The way we draw A and make sure one raw below A in the same lane is
vacant (to avoid something that is not an ancestor of A steals that
spot) is applicable to both graphs.  The reason why we try to keep
one row below A vacant is not because it is a root, but because in
the graph being drawn, none of A's parent will appear.  Obviously if
A is root, none of A's parent will appear in the graph, but in the
latter topology where we are drawing C..Z, none of A's parent will
appear not because A is root, but because all the parents of A is
excluded.