git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC RFC PATCH v2] graph: add --max-columns option to limit displayed columns

From
Pablo <pabloosabaterr@gmail.com>
Date
Mar 18, 2026, 18:20 UTC
Message-ID
<CAN5EUNT7co=ucbBRykXdLJDUdewvoh+cMVbbOOUuRTrv7j2u5A@mail.gmail.com>
In-Reply-To
<xmqqzf45gm2q.fsf@gitster.g>
Thanks for the feedback!
Junio C Hamano (<gitster@pobox.com>) writes:
> "making it difficult"?
I'll correct the typo
> If this <n> refers to the width of graph part only, the option name
> should hint that fact somehow.  Perhaps include the word "graph" in
> it, or something.  As you use the verb "limit" below, perhaps
> "--limit-graph-columns=<n>"?
Show 8 quoted lines
> I would call this output consuming 5 columns for graph part, not 2.
> For end users, being able to specify 2, i.e., being able to say "I
> tolerate wasting display columns to show up to two ancestry lines"
> (or "two lanes of ancestry information"), is indeed a lot more
> intuitive than having to say "You are allowed to use up to 5 display
> columns", so I do not object to an option that takes "2" as its
> value and produces the above output, but I am not sure if we want to
> have "columns" in the name of such an option; "--limit-graph-lanes=2"?

Yes, it only affects the graph rendering, I'll change the name to be more clear about it is for the graph only and that what is being modified are the lanes, "|" + " " not actual single char columns. What about --graph-limit-lanes and make it imply --graph as you said if it's clear enough?

> Isn't "no information is lost" a huge exaggeration?  We are losing
> the ancestry information by not drawing graph lines, aren't we?

Yeah, I meant that most of the commit information is not lost, only where they come from if it's a deeper hidden lane. But what I wanted to say is that internally I'm not removing any information about the graph and that every commit will show no matter the lane limit.

> IIRC, Gitk also allows you to click the chopped arrow-head to jump
> to the other end of the omitted ancestry line, which is very useful
> but is hard to do on a terminal output that is not interactive.

Yes, that's why it's been sooo long without being done prob. But I think this approach is still useful, it can be extended later for more customization like limiting the lines from the left side or ranges. For lane rearrangement I would need to study graph.c more and look forward to refactoring a lot in multiple patches.

> If "git log --max-columns=77" ignores the option because "--graph"
> is not given, it would be confusing to the users.

With the check on 'setup_revision()' users won't be able to 'max-columns=77' if there's no '--graph'

Show 12 quoted lines
> This needs a bit more commenting to explain where these magic
> numbers come from; they are of the same value 2 but have different
> meanings, right?  Like this (only to illustrate the shape, not
> suggesting what the contents should read):
>
>                 /*
>                  * Each ancestry "lane" occupies 2 columns, and
>                  * we leave two columns before drawing the commit
>                  * title and log message part.
>                  */
>                 int max_column_width =
>                         graph->revs->graph_limit_lanes * 2 + 2;

the magic numbers are because, a lane is two columns '|' + ' ', and the +2 comes from the truncation mark '.' + ' ', so for a 3 lanes limit, the padding from the graph should be 3 * 2 + 2 = 8. I'll add a comment to doc the magic numbers.

Show 14 quoted lines
> > +
> > +     if (revs->graph_max_columns > 0 && !revs->graph)
> > +             die(_("option '%s' requires '%s'"), "--max-columns", "--graph");
>
> The naming is so selfish.  Among "git log" options that exists and
> that will be added in the future, this design decision declares that
> "--graph" is and will remain to be the only one that may want to
> specify the maximum number of columns to spend.
>
> If the option is named clearly to be related to the "--graph"
> feature, another way to go is to make it imply "--graph".  If the
> user says "I want to limit the graph output to consume no more than
> 10 leftmost columns", it is clear that the user expects the graph to
> be shown.

I'll make the name clearer about what it does and less selfish. I like the idea about --graph-limit-lanes to imply --graph directly and not force it to be explicit. Making --graph-limit-lanes imply --graph removes the check at revision_setup()

I'll send a v3
Previous: Junio C HamanoNext: Johannes Sixt
Message 6 of 48 in “graph: add --graph-max option to limit displayed columns”
  1. graph: add --graph-max option to limit displayed columnsPablo Sabater, Mar 16, 2026
  2. Karthik NayakMar 16, 2026
  3. PabloMar 16, 2026
  4. graph: add --max-columns option to limit displayed columnsPablo Sabater, Mar 17, 2026
  5. Junio C HamanoMar 18, 2026
  6. PabloMar 18, 2026
  7. Johannes SixtMar 19, 2026
  8. 0/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 22, 2026
  9. 1/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 22, 2026
  10. 2/3 graph: truncate graph visual outputPablo Sabater, Mar 22, 2026
  11. 3/3 graph: add documentation and testing about --graph-lane-limitPablo Sabater, Mar 22, 2026
  12. Junio C HamanoMar 22, 2026
  13. PabloMar 23, 2026
  14. 0/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 23, 2026
  15. 1/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 23, 2026
  16. SZEDER GáborMar 25, 2026
  17. Johannes SixtMar 25, 2026
  18. PabloMar 25, 2026
  19. 2/3 graph: truncate graph visual outputPablo Sabater, Mar 23, 2026
  20. Johannes SixtMar 25, 2026
  21. PabloMar 25, 2026
  22. 3/3 graph: add documentation and tests about --graph-lane-limitPablo Sabater, Mar 23, 2026
  23. Johannes SixtMar 25, 2026
  24. PabloMar 25, 2026
  25. Johannes SixtMar 25, 2026
  26. PabloMar 25, 2026
  27. Johannes SixtMar 25, 2026
  28. PabloMar 25, 2026
  29. 0/2 graph: add --graph-lane-limit optionPablo Sabater, Mar 25, 2026
  30. 1/2 graph: add --graph-lane-limit optionPablo Sabater, Mar 25, 2026
  31. Junio C HamanoMar 25, 2026
  32. PabloMar 27, 2026
  33. PabloMar 27, 2026
  34. Junio C HamanoMar 27, 2026
  35. 2/2 graph: add documentation and tests about --graph-lane-limitPablo Sabater, Mar 25, 2026
  36. 0/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 28, 2026
  37. 1/3 graph: limit the graph width to a hard-coded maxPablo Sabater, Mar 28, 2026
  38. 2/3 graph: add --graph-lane-limit optionPablo Sabater, Mar 28, 2026
  39. 3/3 graph: add truncation mark to capped lanesPablo Sabater, Mar 28, 2026
  40. Junio C HamanoMar 31, 2026
  41. Johannes SixtApr 1, 2026
  42. PabloApr 1, 2026
  43. Junio C HamanoApr 1, 2026
  44. PabloApr 2, 2026
  45. Junio C HamanoApr 2, 2026
  46. Tian YuchenApr 3, 2026
  47. PabloApr 3, 2026
  48. Junio C HamanoApr 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.