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

Re: Supressing sorting of trees

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 12, 2009, 14:20 UTC
Message-ID
<20091012142032.GG9261@spearce.org>
In-Reply-To
<loom.20091012T152113-874@post.gmane.org>
Sal Mangano <smangano@into-technology.com> wrote:
Show 6 quoted lines
> I am using Git in a non-standard way and need to make a few twaeks in my 
> custom build. I have added a --nosort option to git mktree which will suppress
> the qsort of the tree. 
> 
> Will this break any other git functions? Are there any commands that assume 
> trees are always sorted?
_YES IT BREAKS GIT_.
You cannot do this.

A Git repository whose trees are not sorted according to the Git specific sort ordering is severly broken and most tools will fail horribly on it.

Almost all code which reads trees assumes the names are sorted in a specific order. These tools perform sorted merges against other tree like structures. If the names are out of order the merge will fail. `git fsck` will complain that the tree is not sorted properly. Tools like `git log -- foo.c` will fail randomly because they break out of the entry lookup as soon as they find a name that is after foo.c, as they assume the tree is sorted.

I could go on.  But there is no point.

Oh, and trust me when I say this, the tree sorting matters. Long ago JGit had a bug where it didn't sort trees correctly all of the time and we had a devil of a time tracking down that corruption.

-- 
Shawn.
Previous: Sal ManganoNext: Sal Mangano
Message 2 of 9 in “Supressing sorting of trees”
  1. Sal ManganoOct 12, 2009
  2. Shawn O. PearceOct 12, 2009
  3. Sal ManganoOct 12, 2009
  4. Johannes SchindelinOct 12, 2009
  5. Sal ManganoOct 12, 2009
  6. Martin LanghoffOct 12, 2009
  7. Salvatore ManganoOct 12, 2009
  8. Martin LanghoffOct 12, 2009
  9. Ealdwulf WuffingaOct 13, 2009

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.