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

[BUG] git rev-list --no-walk A B C sorts by commit date incorrectly

From
Kevin Ballard <kevin@sb.org>
Date
Jan 8, 2011, 00:19 UTC
Message-ID
<CEF26B82-4281-4B8F-A994-DE32EFB92BA7@sb.org>

----------------------------------------------------------------------------- Running the command `git rev-list --no-walk A B C` should be expected to emit the commits in the same order as they were specified. This is especially important as the same machinery is used for `git cherry-pick`, and so saying `git cherry-pick A B C` can be expected to pick A before B, and B before C.

This does not happen.

Instead, it appears to be sorting the given commits according to the commit timestamp. To make matters worse, it's not a stable sort. If commits A and B have the same timestamp (for example, if they were rebased together), then git cherry-pick tends to apply B before A.

Is there any rationale for this behavior? Any place where it makes sense to reorder the commits in this fashion? As far as I'm concerned, typing `git cherry-pick A B C` should behave identically to typing

  git cherry-pick A
  git cherry-pick B
  git cherry-pick C
regardless of the actual commit dates on A, B, and C.
-Kevin Ballard
Next: Junio C Hamano
Message 1 of 7 in “[BUG] git rev-list --no-walk A B C sorts by commit date incorrectly”
  1. Kevin BallardJan 8, 2011
  2. Junio C HamanoJan 8, 2011
  3. Kevin BallardJan 8, 2011
  4. Junio C HamanoJan 8, 2011
  5. Kevin BallardJan 8, 2011
  6. Junio C HamanoJan 9, 2011
  7. Martin von ZweigbergkJan 12, 2011

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.