I use command like git cat-file -p {tree_hash}
and see, that files sorted in special way. It is not Lexicographical order, because if we have entries in lexicographical order:
entrie,
entrie-dopes,
entrie-hope,
entrie-сase
Git will sort them in order like
entrie-сase,
entrie-dopes,
entrie-hope,
entrie
So my question is: What kind of sorting method is this?.
8
Git sorts entries in trees in lexicographic order using unsigned byte values. Encoding of names like UTF-8 is irrelevant.
There is one exception: Entries that are sub-trees are ordered as if the name has a slash /
appended. For this reason, you get this order:
entrie
entrie-case
entrie=case
when entrie
is a file, but
entrie-case
entrie
entrie=case
when entrie
is a directory.
A remark in the Git source code mentions this.
5