Documentation
¶
Overview ¶
Package gitwt holds the Git plumbing for worker subagents: snapshotting a working tree into a commit without touching the index, creating a linked worktree on its own branch, committing a worker's changes, and applying them back to the parent's working tree atomically.
Every command runs with -C <dir> and an environment stripped of the variables that would redirect git to another repository.
Index ¶
- Constants
- func Apply(top, base, commit string) (conflicts []string, err error)
- func BranchExists(top, branch string) bool
- func ChangedFiles(top, base, commit string) ([]string, error)
- func Commit(path, message string) (commit string, changed bool, err error)
- func Create(top, name, commit string) (path, branch string, err error)
- func DiffStat(top, base, commit string) (stat, short string)
- func Env(extra ...string) []string
- func Head(top string) (string, error)
- func Remove(top, path, branch string)
- func Snapshot(top string) (string, error)
- func Top(dir string) (string, error)
Constants ¶
const ( FallbackName = "tinyagent" FallbackEmail = "tinyagent@localhost" )
FallbackName and FallbackEmail are the identity used for tinyagent's branch-local commits when the repository has no user.name/user.email.
const BranchPrefix = "tinyagent/"
BranchPrefix prefixes every worker branch.
const Dir = ".tinyagent/worktrees"
Dir is where worker worktrees go, relative to the repository root. It is shared with --worktree.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply applies base..commit to the working tree at top (not the index). It is atomic: when any hunk fails, nothing is changed and conflicts lists the affected paths.
func BranchExists ¶
BranchExists reports whether refs/heads/<branch> exists.
func ChangedFiles ¶
ChangedFiles lists the paths, relative to top and slash separated, that base..commit adds, changes or deletes (renames count as both paths).
func Commit ¶
Commit stages every change in the worktree at path (respecting .gitignore) and commits it with message, with repository hooks disabled. changed is false, and no commit is made, when there is nothing to commit.
func Create ¶
Create adds a linked worktree at <top>/.tinyagent/worktrees/<name> on a new branch tinyagent/<name> at commit, with repository hooks disabled. On error nothing new is left behind except the ignored parent directory.
func Env ¶
Env is the environment for tinyagent's own git commands: variables that would point git at a different repository are dropped. extra is appended.
func Remove ¶
func Remove(top, path, branch string)
Remove deletes a worktree and its branch, ignoring errors.
Types ¶
This section is empty.