Skip to main content

Module tree

Module tree 

Source
Expand description

Tree objects — git’s directory representation.

A tree is a sorted list of entries, each pairing a filename with a mode and the object id of its contents. The on-disk encoding of one entry is:

<mode-octal-ascii> SP <name> NUL <raw-oid>

where the mode has no leading zero (40000 for a subtree, 100644 for a regular file) and the id is in fixed-width binary form (20 bytes for SHA-1, 32 for SHA-256). Entries are sorted by name, with subtree names compared as though they ended in / — Tree::serialize re-applies that ordering.

Structs§

Tree
A parsed tree object: its entries in git’s canonical order.
TreeEntry
One entry in a Tree: a mode, a name, and the id of the named object.

Enums§

FileMode
A file mode in a tree entry. Git uses a small fixed set of values rather than full POSIX modes.

Functions§

is_safe_path_component
Validates that name is a single, safe path component fit to be joined onto a working-tree (or .git-relative) path derived from untrusted input — a malicious tree, index, or ref can carry names crafted to escape the directory or clobber the git metadata directory.