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