View order of a list of git commits
Asked Answered
H

1

7

I have a list of commit hashes and I need to order them chronologically.

I thought I could get git rev-list to do it, but it insists on showing me all the commits even if I specify a commit on the command line.

Is there a way to make git do this or do I have to combine git rev-list and grep?

Thanks!

Hintz answered 10/11, 2016 at 16:53 Comment(1)
Read this it will give you few ideas. thesimplesynthesis.com/post/…Virtuosity
V
6

Use the --no-walk option. It works on everything based off git rev-list.

Vachil answered 10/11, 2016 at 17:26 Comment(4)
Specifically, you can now --no-walk=sorted or --no-walk=unsorted, and the default is "sorted". In older versions of Git, though, --no-walk is always unsorted, so beware! (This bit me when I tried to use it back in the Git 1.7ish or 1.8ish days.)Haunt
? I upvoted your comment on faith, but 8e64006 which introduced the option says the rev-list-based commands sort their output (by default, now), it's git show that follows command line order. Could you be misremembering? @HauntVachil
It was quite an older Git. I'd have to dig through the history inside Git to see when this was fixed. My script had these four lines (comment will collapse them of course) # parse the arguments into one file git rev-parse $@ > $TF1 || exit 1 # and topo-sort the arguments into another git rev-list --topo-order --no-walk --reverse $@ > $TF2 || exit 1 and it failed until some Git uprev fixed this. (The last time I touched this script was 2012, so the problem occurred in 2012 or earlier.)Haunt
(It looks like that would be Git 1.6, then, or maybe an early 1.7 version.) Addendum: probably commit fbc08ea177f8284d10c62ad39de51edb21af88b0 which means it would be broken (unsorted) in 1.7.10 and earlier.Haunt

© 2022 - 2024 — McMap. All rights reserved.