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

Re: Odd rev-list behaviour

From
Jeff King <peff@peff.net>
Date
Apr 24, 2015, 01:52 UTC
Message-ID
<20150424015234.GA2001@peff.net>
In-Reply-To
<CAPR6cbD5uFoCDg73wqSQEPOuUEjsy6963QQsePwofxVTuBW8Ew@mail.gmail.com>
On Fri, Apr 24, 2015 at 12:48:43AM +0100, B M Corser wrote:
> Seeing some weird results out of rev-list, see my demo repo:
> https://github.com/bmcorser/rev-list-fail

That repo has a whole bunch of commits with identical committer timestamps. The default order that git displays those in is going to depend on the order you provide them in.

> I was after a one-liner to sort a bunch of commit hashes into
> topological (or date) order. The commits were made by a script that
> forges the commit time with --date in the hope of seeing stable
> results.

Using "--date" will just set the author date. You probably want to set GIT_COMMITTER_DATE in the environment if you are scripting imported commits from somewhere else (or better yet, consider using git-fast-import if you have a lot of commits).

Even with identical commit timestamps, we should be able to show the commits in topo-order. Your README.md shows you trying:

  git rev-list --no-walk $(git log --format=%H | shuf)

That is missing any mention of --topo-order, of course. But even adding that in, it does not seem to work, which is perhaps what you are getting at. I am not sure whether "--no-walk" plays well with other sorting options, and that may be the problem.

Is there a reason that just:
  git rev-list --topo-order HEAD

does not serve your purpose? It's hard to tell what you're trying to achieve from this obviously toy repository.

In the meantime, you can also pipe the output of "rev-list" into your own sort routine, using --format to get whatever information you need (you can topo-sort with the information from --parents).

-Peff
Previous: B M Corser
Message 2 of 2 in “Odd rev-list behaviour”
  1. B M CorserApr 23, 2015
  2. Jeff KingApr 24, 2015

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.