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.