module documentation
Porcelain for git subtree operations.
| Function | subtree |
Add a subtree to the repository. |
| Function | subtree |
Merge changes into an existing subtree. |
| Function | subtree |
Pull changes from a remote repository into a subtree. |
| Function | subtree |
Push a subtree to a remote repository. |
| Function | subtree |
Split a subtree into a separate branch. |
| Function | _create |
Create a subtree commit with standard metadata. |
def subtree_add(repo:
RepoPath, prefix: bytes | str, repository: str | None = None, ref: bytes | str | None = None, commit: bytes | str | Commit | Tag | None = None, squash: bool = False, message: bytes | None = None) -> ObjectID:
¶
Add a subtree to the repository.
| Parameters | |
repo:RepoPath | Repository to add subtree to |
prefix:bytes | str | Directory path where subtree will be added |
repository:str | None | URL of repository to add (for remote subtrees) |
ref:bytes | str | None | Ref to fetch from repository |
commit:bytes | str | Commit | Tag | None | Commit object to add (for local subtrees) |
squash:bool | If True, squash history into a single commit |
message:bytes | None | Custom commit message |
| Returns | |
ObjectID | Object ID of the new commit |
| Raises | |
Error | If prefix already exists or commit cannot be found |
ValueError | If neither (repository, ref) nor commit is provided |
def subtree_merge(repo:
RepoPath, prefix: bytes | str, commit: bytes | str | Commit | Tag, squash: bool = False, message: bytes | None = None) -> ObjectID:
¶
Merge changes into an existing subtree.
| Parameters | |
repo:RepoPath | Repository to merge into |
prefix:bytes | str | Directory path of the subtree |
commit:bytes | str | Commit | Tag | Commit to merge |
squash:bool | If True, squash history into a single commit |
message:bytes | None | Custom commit message |
| Returns | |
ObjectID | Object ID of the merge commit |
| Raises | |
Error | If prefix doesn't exist or merge fails |
def subtree_pull(repo:
RepoPath, prefix: bytes | str, repository: str, ref: bytes | str, squash: bool = False, message: bytes | None = None) -> ObjectID:
¶
Pull changes from a remote repository into a subtree.
| Parameters | |
repo:RepoPath | Repository to pull into |
prefix:bytes | str | Directory path of the subtree |
repository:str | URL of repository to pull from |
ref:bytes | str | Ref to fetch |
squash:bool | If True, squash history into a single commit |
message:bytes | None | Custom commit message |
| Returns | |
ObjectID | Object ID of the merge commit |
| Raises | |
Error | If fetch or merge fails |
def subtree_split(repo:
RepoPath, prefix: bytes | str, branch: bytes | str | None = None, rejoin: bool = False, onto: bytes | str | None = None) -> ObjectID:
¶
Split a subtree into a separate branch.
| Parameters | |
repo:RepoPath | Repository to split from |
prefix:bytes | str | Directory path of the subtree to split |
branch:bytes | str | None | Branch name to create (optional) |
rejoin:bool | If True, merge the split branch back with metadata |
onto:bytes | str | None | Commit to use as the initial parent (optional) |
| Returns | |
ObjectID | Object ID of the split commit |
| Raises | |
Error | If prefix doesn't exist |
def _create_subtree_commit(repo:
Repo, tree_id: ObjectID, parents: list[ ObjectID], message: bytes, base_commit: Commit) -> ObjectID:
¶
Create a subtree commit with standard metadata.
| Parameters | |
repo:Repo | Repository to create commit in |
treeObjectID | Tree ID for the commit |
parents:list[ | Parent commit IDs |
message:bytes | Commit message (with trailers already added) |
baseCommit | Base commit to copy author/committer info from |
| Returns | |
ObjectID | Object ID of the new commit |