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
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2026, 16:05 UTC
Message-ID
<xmqqzf45gm2q.fsf@gitster.g>
In-Reply-To
<20260317220929.120746-1-pabloosabaterr@gmail.com>
Pablo Sabater <pabloosabaterr@gmail.com> writes:
> Repositories that have many active branches produce very wide
> outputs with 'git log --graph --all', makes it difficult to read.
"making it difficult"?
> Add '--max-columns=<n>' to limit the columns shown. Columns over
> the limit are replaced with a '.' truncation indicator. This only
> affects the visual rendering.

Being an option to "git log", I expect that readers would naturally take "--max-columns=<n>" to refer to the total display width consumed by the entire output including the log messages and possibly patches when the command is run with the "-p" option, whether the ancestry graph is shown or not.

But somehow I suspect that it is not what is going on here.

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>"?

> The commit mark '*' is only shown in two cases:
> - The commit is in a branch inside the limit.
> - The commit is in the first hidden branch, in this case '.'
>   is replaced by '*'.
> Commits on deeper hidden branches do not show '*' but the commit
> subject is still shown, so no information is lost.

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

> The original idea to limit columns was noted as a TODO in
> c12172d2ea (Add history graph API, 2008-05-04), which mentions
> gitk's behavior. This does not implement gitk-style column
> rearrangement; it only truncates the visual output.
True.  

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.

Show 5 quoted lines
> git log --graph --all --oneline --max-columns=2
> *   b81d099 (M_1) 7_M1
> |\
> | | * 2d96ba0 (M_3) 7_M2
> | | .

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"?

> - I think --max-columns is a good name, but it does not have --graph
>   prefix, bcs it can only be on --graph I think it's clear enough.

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

Show 5 quoted lines
> +	/*
> +	 * If graph_max_columns is set, cap the padding from the branches
> +	 */
> +	if (graph->revs->graph_max_columns > 0) {
> +		int truncation = graph->revs->graph_max_columns * 2 + 2;

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;
> +
> +	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.

Previous: Pablo SabaterNext: Pablo
Message 5 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.