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