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

Re: Exact format of tree objets

From
Chico Sokol <chico.sokol@gmail.com>
Date
Jun 18, 2013, 15:15 UTC
Message-ID
<CABx5MBTtvyZT+TUj6iibFngbMnGoDvFT2wXM6oDACtuJ46kR7Q@mail.gmail.com>
In-Reply-To
<20130611182649.GA24704@LK-Perkele-VII>
What is the encoding of the filename?

-- Chico Sokol

On Tue, Jun 11, 2013 at 3:26 PM, Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:

Show 31 quoted lines
> On Tue, Jun 11, 2013 at 01:25:14PM -0300, Chico Sokol wrote:
>> Is there any official documentation of tree objets format? Are tree
>> objects encoded specially in some way? How can I parse the inflated
>> contents of a tree object?
>
> Tree object consists of entries, each concatenation of:
> - Octal mode (using ASCII digits 0-7).
> - Single SPACE (0x20)
> - Filename
> - Single NUL (0x00)
> - 20-byte binary SHA-1 of referenced object.
>
> At least following octal modes are known:
> 40000: Directory (tree).
> 100644: Regular file (blob).
> 100755: Executable file (blob).
> 120000: Symbolic link (blob).
> 160000: Submodule (commit).
>
> The entries are always sorted in (bytewise) lexicographical order,
> except directories sort like there was impiled '/' at the end.
>
> So e.g.:
> ! < 0 < 9 < a < a- < a- (directory) < a (directory) < a0 < ab < b < z.
>
>
> The idea of sorting directories specially is that if one recurses
> upon hitting a directory and uses '/' as path separator, then the
> full filenames are in bytewise lexicographical order.
>
> -Ilari
Previous: Ilari LiusvaaraNext: Thomas Rast
Message 3 of 7 in “Exact format of tree objets”
  1. Chico SokolJun 11, 2013
  2. Ilari LiusvaaraJun 11, 2013
  3. Chico SokolJun 18, 2013
  4. Thomas RastJun 18, 2013
  5. Junio C HamanoJun 11, 2013
  6. Jakub NarebskiJun 12, 2013
  7. Chico SokolJun 18, 2013

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.