module documentation
Git subtree implementation.
| Class | |
Metadata stored in commit trailers for subtree operations. |
| Function | add |
Add subtree metadata trailers to a commit message. |
| Function | create |
Create a new tree with a subtree inserted at the given prefix. |
| Function | extract |
Extract a subtree from a tree at the given prefix path. |
| Function | find |
Find previous subtree split commits in history. |
| Function | parse |
Parse subtree metadata from commit message trailers. |
| Function | _validate |
Validate that a prefix is a valid path. |
def create_tree_with_subtree(store:
BaseObjectStore, base_tree: Tree | None, prefix: bytes, subtree: Tree) -> ObjectID:
¶
Create a new tree with a subtree inserted at the given prefix.
| Parameters | |
store:BaseObjectStore | Object store to write to |
baseTree | None | Base tree to insert into (None for empty tree) |
prefix:bytes | Path where subtree should be inserted (e.g., b"vendor/lib") |
subtree:Tree | Tree to insert |
| Returns | |
ObjectID | Object ID of the new tree |
| Raises | |
ValueError | If prefix is invalid |
Extract a subtree from a tree at the given prefix path.
| Parameters | |
store:BaseObjectStore | Object store to read from |
tree:Tree | Tree object to extract from |
prefix:bytes | Path to subtree (e.g., b"vendor/lib") |
| Returns | |
Tree | None | Tree object for the subtree, or None if path doesn't exist |
| Raises | |
ValueError | If prefix is invalid |
def find_subtree_splits(store:
BaseObjectStore, commit: Commit, prefix: bytes, limit: int | None = None) -> list[ tuple[ ObjectID, ObjectID]]:
¶
Find previous subtree split commits in history.
| Parameters | |
store:BaseObjectStore | Object store to read from |
commit:Commit | Starting commit |
prefix:bytes | Subtree prefix to search for |
limit:int | None | Maximum number of splits to find (None for all) |
| Returns | |
list[ | List of (commit_id, split_id) tuples for commits with subtree metadata |
Parse subtree metadata from commit message trailers.
| Parameters | |
commit:Commit | Commit to parse metadata from |
| Returns | |
SubtreeMetadata | Dictionary with subtree metadata (dir, split, mainline) |
Validate that a prefix is a valid path.
| Parameters | |
prefix:bytes | Path prefix to validate |
| Raises | |
ValueError | If prefix is invalid |