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

Re: Why are ref_lists sorted?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 19, 2007, 17:03 UTC
Message-ID
<Pine.LNX.4.64.0703190935360.6730@woody.linux-foundation.org>
In-Reply-To
<Pine.LNX.4.64.0703190321370.28570@beast.quantumfyre.co.uk>
On Mon, 19 Mar 2007, Julian Phillips wrote:
> 
> So my questions are:
> 
> 1) what have I broken by removing the sort?
The big thing is probably consistency.

I *really* think we need to sort these things. Otherwise you'll see two totally identical repositories giving different results to something as fundamental as "git ls-remote" just because they didn't get sorted.

So I think sorting is absolutely required, perhaps not so much because it is necessarily "incorrect" without the sorting, but because I think consistency in this area is too important *not* to sort it.

And sorting it really is simple. The fact that we use a O(n**2) list insertion thing that is also probably pessimal for the case of "already sorted" input is just a "hey, it was easy, we never actually hit it in practice" issue.

> 2) is it worth trying to optimise the sort?

Absolutely. It might involve changing the "ref_list *" thing into an array of ref_entries, and that will cause a lot of (fairly trivial) changes, but it should all be entirely internal to refs.c, so it's hopefully not painful, just some boring grunt-work.

		Linus
Previous: Junio C Hamano
Message 7 of 7 in “Why are ref_lists sorted?”
  1. Julian PhillipsMar 19, 2007
  2. Junio C HamanoMar 19, 2007
  3. Shawn O. PearceMar 19, 2007
  4. Julian PhillipsMar 19, 2007
  5. Shawn O. PearceMar 19, 2007
  6. Junio C HamanoMar 19, 2007
  7. Linus TorvaldsMar 19, 2007

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.