diff options
| author | 2026-06-07 11:11:36 +0000 | |
|---|---|---|
| committer | 2026-06-07 11:11:36 +0000 | |
| commit | 7e624857a3c57e927d27ecab4dea8ef20d90159b (patch) | |
| tree | 6530b9556cc9e2f62d7bd7de19085eb04cd3fe9d /object/tree/tree.go | |
| parent | object/tree/mode: Initialize (diff) | |
object/tree: Add basic tree functions
Diffstat (limited to 'object/tree/tree.go')
| -rw-r--r-- | object/tree/tree.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/object/tree/tree.go b/object/tree/tree.go new file mode 100644 index 00000000..431df649 --- /dev/null +++ b/object/tree/tree.go @@ -0,0 +1,35 @@ +package tree + +import ( + "slices" + + "lindenii.org/go/furgit/object/id" + "lindenii.org/go/furgit/object/tree/mode" +) + +// Tree represents a fully materialized Git tree object. +// +// The zero value is an empty tree. +// Entries are stored sorted by Git tree ordering and are duplicate-free; +// use [Tree.Insert] to add entries and [Tree.Entries] to read them. +// +// Labels: MT-Unsafe. +type Tree struct { + entries []Entry +} + +// Entry represents a single entry in a tree. +type Entry struct { + Mode mode.Mode + Name string + ID id.ObjectID +} + +// Entries returns a copy of the tree's entries in Git tree order. +// +// Mutating the returned slice does not affect the tree. +// +// Labels: Life-Independent. +func (tree *Tree) Entries() []Entry { + return slices.Clone(tree.entries) +} |
