git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How Does "git log --reverse" Work?
@ 2025-12-30  0:18 Jon Forrest
  2025-12-30  2:04 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Forrest @ 2025-12-30  0:18 UTC (permalink / raw)
  To: git

I'm trying to understand how 'git log --reverse' displays
commits in reverse order (i.e. oldest commit first).

The fact that each commit object has pointer(s) to parent
object(s) makes it trivial to go newest to oldest.
But, I haven't found a way to go oldest to newest.

I've looked at the code but it's not well commented.
Does the answer have something to do with commit lists?

Any advice would be appreciated.

Cordially,
Jon Forrest


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How Does "git log --reverse" Work?
  2025-12-30  0:18 How Does "git log --reverse" Work? Jon Forrest
@ 2025-12-30  2:04 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2025-12-30  2:04 UTC (permalink / raw)
  To: Jon Forrest; +Cc: git

Jon Forrest <nobozo@gmail.com> writes:

> I've looked at the code but it's not well commented.
> Does the answer have something to do with commit lists?

What revision.c:get_revision() does should be fairly obvious.

When the .reverse option is in effect, it grabs all the commits it
needs to show (with the usual traversal, as if .reverse were not in
effect, by calling get_revision_internal()), queues it in the
.commits list, goes into the reverse output stage, where we output
what we queued earlier.  After that, we yield commits from that
queue.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-30  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30  0:18 How Does "git log --reverse" Work? Jon Forrest
2025-12-30  2:04 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).