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

'git rev-list' commit ordering issue

From
CMClement Moyroud <clement.moyroud@gmail.com>
Date
Feb 26, 2025, 01:43 UTC
Message-ID
<CABXAcUxHp3LnyqR=NM0coh6wG-1uy4GB3FdeZEg8mPHu-vt0bQ@mail.gmail.com>
Hello,

I've come across an issue with `git rev-list --no-walk=sorted` commit ordering when two commits have the exact same commit date. In that case, `git rev-list` will leave the two commits in the original order, preventing automated cherry-picking.

To reproduce starting from the attached repo archive created with `git bugreport`: git rev-list --reverse HEAD | git rev-list --no-walk=sorted --stdin

You'll see that the order of the two middle commits is incorrect and does not match the order returned by `git rev-list HEAD`

Since both commits have the same commit date, `git rev-list` should use another criterion to do the sorting - namely, use the parent/child topology.

If there are better ways to sort such a list, let me know. This is a much simplified test case. In our real-world application, we start from a subset of commits that we want to cherry-pick from a branch, for the purpose of creating a customer-specific patch build. For the automated cherry-pick to work, we need to have these commits sorted in topological order. I do not see an option to `git rev-list` that only sorts the commits in stdin topologically - the `--no-walk` option only does date-based sorting.

Below is the system info gathered by `git bugreport`.
Take care,
Clement
[System Info]
git version:
git version 2.48.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 7.87.0
OpenSSL: OpenSSL 1.0.1e-fips 11 Feb 2013
zlib: 1.2.3
uname: Linux 4.18.0-553.33.1.el8_10.x86_64 #1 SMP Thu Dec 19 14:28:01
UTC 2024 x86_64
compiler info: gnuc: 6.2
libc info: glibc: 2.28
$SHELL (typically, interactive shell): /bin/zsh
[Enabled Hooks]
Next: D. Ben Knoble
Message 1 of 5 in “'git rev-list' commit ordering issue”
  1. Clement MoyroudFeb 26, 2025
  2. D. Ben KnobleFeb 26, 2025
  3. Clement MoyroudFeb 26, 2025
  4. Phillip WoodFeb 28, 2025
  5. Clement MoyroudFeb 28, 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.