From: Jeff King <peff@peff.net>
To: Kristofer Karlsson <krka@spotify.com>
Cc: Pablo Sabater <pabloosabaterr@gmail.com>,
git@vger.kernel.org, ayu.chandekar@gmail.com,
chandrapratap3519@gmail.com, christian.couder@gmail.com,
gitster@pobox.com, jltobler@gmail.com, karthik.188@gmail.com,
phillip.wood@dunelm.org.uk, siddharthasthana31@gmail.com
Subject: Re: [PATCH v5 2/2] graph: indent visual root in graph
Date: Sun, 21 Jun 2026 14:05:56 -0400 [thread overview]
Message-ID: <20260621180556.GD2206349@coredump.intra.peff.net> (raw)
In-Reply-To: <CAL71e4MAtD4MqE-22UyYaNFVYcFgYmffngihhovEChVfHLmEdA@mail.gmail.com>
On Fri, Jun 19, 2026 at 09:34:16AM +0200, Kristofer Karlsson wrote:
> On Thu, 18 Jun 2026 at 18:05, Jeff King <peff@peff.net> wrote:
> >
> > Thanks for looking into it. I meant to also cc the Kristofer, the author
> > of dd4bc01c0a, for any thoughts (adding him now).
> >
>
> Thanks for the CC. I took a look at how this interacts with my
> change.
>
> dd4bc01c0a doesn't hurt here I think, but future followup changes
> might. From what I can tell --graph triggers topo_order, so
> the walk mode is either REV_WALK_TOPO or REV_WALK_LIMITED
> and the prio_queue change only applies to REV_WALK_STREAMING.
I'm not so sure. If I merge 53967f242a (graph: indent visual root in
graph, 2026-06-13) into master (so that it has both your commit_queue
changes and Pablo's topic), and then apply this:
diff --git a/graph.c b/graph.c
index e0d1e2a510..8a5f17a089 100644
--- a/graph.c
+++ b/graph.c
@@ -926,6 +926,10 @@ static void graph_peek_next_visible(struct git_graph *graph,
flags->is_next_visual_root = 0;
flags->next_has_column = 0;
+ warning("peeking at visible commits: %d in list, %d in queue",
+ commit_list_count(graph->revs->commits),
+ (int)graph->revs->commit_queue.nr);
+
for (cl = graph->revs->commits; cl; cl = cl->next) {
if (get_commit_action(graph->revs, cl->item) != commit_show)
continue;
and run:
./git log --graph -- Makefile
then we always see exactly one commit in the list, but an
ever-increasing number in the queue (up to ~4000). We do seem to be in
REV_WALK_TOPO mode, so I think we'd never return the commits via
get_revision(), but it is weird that we are sticking them in the queue
at all.
Looks like that happens via rewrite_parents(), which always writes into
commit_queue. I guess it doesn't matter because in topo mode we are
always pulling off of the topo_walk_info queue anyway? It does make me
wonder if there is a lurking bug around history simplification and
--topo-order, though.
> That said, graph_peek_next_visible() reaching directly into
> revs->commits feels fragile -- especially if we drop revs->commits
> in the future. One option would be to add a thin abstraction in
> revision.c that dispatches per walk mode, something like:
>
> int revision_has_more_commits(struct rev_info *revs)
> {
> if (revs->topo_walk_info)
> return revs->topo_walk_info->topo_queue.nr > 0;
> return revs->commits != NULL;
> }
>
> struct commit *revision_peek_next_commit(struct rev_info *revs)
> {
> if (revs->topo_walk_info)
> return prio_queue_peek(&revs->topo_walk_info->topo_queue);
> if (revs->commits)
> return revs->commits->item;
> return NULL;
> }
>
> That way graph.c does not need to know which data structure the
> walker uses, and if the internals change later the API adapts in
> one place.
Yeah, I agree some abstraction would help. I think it would have to be
full iteration, though; the graph code wants to know if there is any
commit that is actually going to be shown, not just a potential single
next one. So we at least need to be able to iterate in arbitrary order.
> As for the multi-element peek question, I think I would either opt
> for draining into a buffer if it's really needed, though when looking
> at the code here I think multi-element peeking is not truly needed.
> It seems like the logic just checks if there is at least another
> element after the peek, but it does not try to read the actual value,
> so we can just check the queue size instead.
We do look at some characteristics of the commit we find by peeking, but
I'm not sure how much it matters if we get the _next_ commit that will
be shown, or if any arbitrary commit is OK.
-Peff
next prev parent reply other threads:[~2026-06-21 18:05 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 21:17 [GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root Pablo Sabater
2026-04-02 21:17 ` [GSoC RFC PATCH 1/1] " Pablo Sabater
2026-04-03 17:55 ` Junio C Hamano
2026-04-03 18:07 ` Pablo
2026-04-03 5:04 ` [GSoC RFC PATCH 0/1] " Junio C Hamano
2026-04-03 8:25 ` Pablo
2026-04-04 9:24 ` [GSoC RFC PATCH v2 0/1] graph: add indentation for commits preceded by a parentless commit Pablo Sabater
2026-04-04 9:24 ` [GSoC RFC PATCH v2 1/1] " Pablo Sabater
2026-04-10 16:25 ` [GSoC RFC PATCH v2 0/1] " Pablo
2026-04-10 16:54 ` Junio C Hamano
2026-04-27 10:28 ` [GSoC PATCH v3 " Pablo Sabater
2026-04-27 10:28 ` [GSoC PATCH v3 1/1] " Pablo Sabater
2026-05-13 23:02 ` Jeff King
2026-05-14 10:19 ` Pablo Sabater
2026-04-27 10:35 ` [GSoC PATCH v3 0/1] " Pablo
2026-06-12 13:48 ` [PATCH v4 0/2] graph: indent visual roots in graph Pablo Sabater
2026-06-12 13:48 ` [PATCH v4 1/2] lib-log-graph: move check_graph function Pablo Sabater
2026-06-12 13:48 ` [PATCH v4 2/2] graph: indent visual root in graph Pablo Sabater
2026-06-13 3:01 ` [PATCH v4 0/2] graph: indent visual roots " Junio C Hamano
2026-06-13 19:09 ` [PATCH v5 " Pablo Sabater
2026-06-13 19:09 ` [PATCH v5 1/2] lib-log-graph: move check_graph function Pablo Sabater
2026-06-13 19:09 ` [PATCH v5 2/2] graph: indent visual root in graph Pablo Sabater
2026-06-14 4:05 ` Junio C Hamano
2026-06-14 5:28 ` Pablo Sabater
2026-06-15 15:42 ` Junio C Hamano
2026-06-16 13:06 ` Pablo Sabater
2026-06-16 16:36 ` Junio C Hamano
2026-06-17 20:27 ` Jeff King
2026-06-18 12:42 ` Pablo Sabater
2026-06-18 13:31 ` Junio C Hamano
2026-06-18 16:05 ` Jeff King
2026-06-18 16:07 ` Jeff King
2026-06-19 7:34 ` Kristofer Karlsson
2026-06-21 18:05 ` Jeff King [this message]
2026-06-22 8:29 ` Kristofer Karlsson
2026-06-17 10:33 ` [PATCH v5 0/2] graph: indent visual roots " Chandra Pratap
2026-06-20 10:11 ` [PATCH v6 0/3] " Pablo Sabater
2026-06-20 10:11 ` [PATCH v6 1/3] lib-log-graph: move check_graph function Pablo Sabater
2026-06-20 10:11 ` [PATCH v6 2/3] revision: add peek functions for lookahead Pablo Sabater
2026-06-20 10:18 ` Pablo Sabater
2026-06-20 14:56 ` Junio C Hamano
2026-06-20 15:15 ` Junio C Hamano
2026-06-21 1:48 ` Junio C Hamano
2026-06-21 6:42 ` Chandra Pratap
2026-06-22 8:28 ` Kristofer Karlsson
2026-06-20 10:11 ` [PATCH v6 3/3] graph: indent visual root in graph Pablo Sabater
2026-05-14 15:15 ` [GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root Phillip Wood
2026-05-14 17:45 ` Pablo Sabater
2026-05-15 9:33 ` Phillip Wood
2026-05-17 6:31 ` Chandra Pratap
2026-05-18 13:26 ` Pablo Sabater
2026-05-19 0:03 ` Junio C Hamano
2026-05-19 5:59 ` Pablo Sabater
2026-06-10 15:21 ` Junio C Hamano
2026-06-10 15:28 ` Pablo Sabater
2026-05-19 10:39 ` Chandra Pratap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260621180556.GD2206349@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=ayu.chandekar@gmail.com \
--cc=chandrapratap3519@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=krka@spotify.com \
--cc=pabloosabaterr@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=siddharthasthana31@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox