{"thread":{"id":"64695","subject":"How Does \"git log --reverse\" Work?","startedAt":"2025-12-30T00:18:58Z","lastAt":"2025-12-30T02:04:45Z","messageCount":2,"participants":["Jon Forrest","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"532816","messageId":"16fc8ecb-01f7-4056-be58-e3aa20345f77@gmail.com","threadId":"64695","inReplyTo":null,"subject":"How Does \"git log --reverse\" Work?","fromName":"Jon Forrest","fromEmail":"nobozo@gmail.com","sentAt":"2025-12-30T00:18:55Z","receivedAt":"2025-12-30T00:18:58Z","isPatch":false,"sender":{"key":"nobozo@gmail.com","avatar":"https://gravatar.com/avatar/37c6a7b57f29b3f35c6a9016537907c52f15bbf98575617dc046bcec6bf06372?d=mp&s=160"},"body":"I'm trying to understand how 'git log --reverse' displays\ncommits in reverse order (i.e. oldest commit first).\n\nThe fact that each commit object has pointer(s) to parent\nobject(s) makes it trivial to go newest to oldest.\nBut, I haven't found a way to go oldest to newest.\n\nI've looked at the code but it's not well commented.\nDoes the answer have something to do with commit lists?\n\nAny advice would be appreciated.\n\nCordially,\nJon Forrest\n\n"},{"id":"532819","messageId":"xmqqy0mkhghx.fsf@gitster.g","threadId":"64695","inReplyTo":"16fc8ecb-01f7-4056-be58-e3aa20345f77@gmail.com","subject":"Re: How Does \"git log --reverse\" Work?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-30T02:04:42Z","receivedAt":"2025-12-30T02:04:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Forrest <nobozo@gmail.com> writes:\n\n> I've looked at the code but it's not well commented.\n> Does the answer have something to do with commit lists?\n\nWhat revision.c:get_revision() does should be fairly obvious.\n\nWhen the .reverse option is in effect, it grabs all the commits it\nneeds to show (with the usual traversal, as if .reverse were not in\neffect, by calling get_revision_internal()), queues it in the\n.commits list, goes into the reverse output stage, where we output\nwhat we queued earlier.  After that, we yield commits from that\nqueue.\n"}]}