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

Re: How Does "git log --reverse" Work?

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 30, 2025, 02:04 UTC
Message-ID
<xmqqy0mkhghx.fsf@gitster.g>
In-Reply-To
<16fc8ecb-01f7-4056-be58-e3aa20345f77@gmail.com>
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.

Previous: Jon Forrest
Message 2 of 2 in “How Does "git log --reverse" Work?”
  1. Jon ForrestDec 30, 2025
  2. Junio C HamanoDec 30, 2025

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.