Documentation
¶
Index ¶
- Variables
- func AddWorktreeRecoveryRows(list []vcs.WorktreeInfo, infos []contextstate.WorktreeInstanceInfo) []vcs.WorktreeInfo
- func AdoptManagedWorktree(root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
- func BeginManagedWorktreeRemoval(root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
- func BeginManagedWorktreeRemovalForSession(sess *chat.Session, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
- func BeginManagedWorktreeRemovalForSessionExpected(sess *chat.Session, root string, wt *vcs.WorktreeInfo, ...) (contextstate.WorktreeInstance, error)
- func BeginManagedWorktreeRemovalInStore(store *storage.SQLite, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
- func BeginManagedWorktreeRemovalInStoreExpected(store *storage.SQLite, root string, wt *vcs.WorktreeInfo, ...) (contextstate.WorktreeInstance, error)
- func CanonicalMarkerRoot(root string) (string, error)
- func ClassifyMissingWorktreeMarker(store *storage.SQLite, principal contextstate.Principal, ...) (contextstate.WorktreeInstanceInfo, bool, error)
- func CleanupStaleWorktreeRows(store *storage.SQLite, principal contextstate.Principal, name string) (bool, error)
- func CreateManagedWorktree(root, name, baseRef, branchPrefix string) (*vcs.WorktreeInfo, error)
- func CreateManagedWorktreeInStore(store *storage.SQLite, root, name, baseRef, branchPrefix string) (*vcs.WorktreeInfo, error)
- func CreateManagedWorktreeInStoreLocked(store *storage.SQLite, root, name, baseRef, branchPrefix string, ...) (*vcs.WorktreeInfo, error)
- func CreateManagedWorktreeInStoreWithInstance(store *storage.SQLite, root, name, baseRef, branchPrefix string, ...) (*vcs.WorktreeInfo, error)
- func FinishManagedWorktreeRemoval(root string, instance contextstate.WorktreeInstance) error
- func FinishManagedWorktreeRemovalInStore(store *storage.SQLite, root string, instance contextstate.WorktreeInstance) error
- func LockWorktreeLifecycle(root, name string) (*worktreeLifecycleLock, error)
- func LockWorktreeMarkerFile(file *os.File) (func(), error)
- func OpenMarkerExcludeLockFile(root *os.Root, path string) (*os.File, error)
- func ReactivateManagedWorktree(root string, instance contextstate.WorktreeInstance) error
- func ReactivateManagedWorktreeInStore(store *storage.SQLite, root string, instance contextstate.WorktreeInstance) error
- func ReadMarkerAtCanonicalRoot(root string) (contextstate.WorktreeInstance, string, error)
- func ReadWorktreeMarker(root string) (contextstate.WorktreeInstance, error)
- func RecoverManagedWorktreeCreationInStore(store *storage.SQLite, root string, info contextstate.WorktreeInstanceInfo) (*vcs.WorktreeInfo, error)
- func RecoverManagedWorktreeRemoval(root, name, branchPrefix string) (bool, error)
- func RecoverManagedWorktreeRemovalInfoInStoreLocked(store *storage.SQLite, root string, info contextstate.WorktreeInstanceInfo, ...) error
- func RegisterManagedWorktreeInStore(store *storage.SQLite, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
- func RegisterWorktreeRoute(root string, wt *vcs.WorktreeInfo) error
- func RemoveUnmanagedWorktree(root string, wt *vcs.WorktreeInfo, branchPrefix string, lease *os.File) error
- func RemoveWorktreeLocked(root, name, branchPrefix string, lease *os.File) (bool, error)
- func RemoveWorktreeRoute(root, name string) error
- func RemoveWorktreeRouteForSession(sess *chat.Session, root, name string) error
- func RunWorktree(args []string) error
- func RunWorktreeWithIO(args []string, stdout io.Writer) error
- func SnapshotWorktreeDialogBindings(store *storage.SQLite, principal contextstate.Principal, ...) map[string]WorktreeDialogBinding
- func ValidateExpectedWorktreeInstanceInStore(store *storage.SQLite, root, dir string, ...) error
- func WorktreeContainsCurrentDir(path string) bool
- func WorktreeMarkerPath(root string) string
- func WorktreeRecoveryLabel(state contextstate.WorktreeInstanceState) string
- func WorktreeRoutePrincipal(root string) (contextstate.Principal, error)
- func WriteWorktreeList(stdout io.Writer, worktrees []vcs.WorktreeInfo, ...)
- func WriteWorktreeMarker(root string, instance contextstate.WorktreeInstance) error
- type WorktreeDialogBinding
- type WorktreeRecoveryRow
Constants ¶
This section is empty.
Variables ¶
var ( StatWorktreeSwitchPath = os.Stat AbsWorktreeSwitchPath = filepath.Abs EvalWorktreeSwitchPath = filepath.EvalSymlinks GetwdWorktreeSwitch = os.Getwd RelWorktreeSwitchPath = filepath.Rel )
var CanonicalWorktreeDialogRoot = CanonicalMarkerRoot
CanonicalWorktreeDialogRoot is the canonical worktree dialog root value.
var ErrUnmanagedWorktree = errors.New("worktree has no managed lifecycle binding")
ErrUnmanagedWorktree marks a worktree that has no valid lifecycle binding: its marker is unreadable or its instance is not active in storage. The caller removes the physical worktree directly and cleans storage rows by name, so HDD space is freed even when the storage layer has no entry.
var OpenRepositoryContextStoreFunc func(root string) (*storage.SQLite, error)
OpenRepositoryContextStoreFunc opens the repository-level context store for root. Wired by internal/cli's init (see cli.wireCliworktree) rather than imported directly: cli's own repository-store resolution (repositorySessionStorePath in chat_repository_binding.go) needs worktree helpers this package exports (WorktreeRoutePrincipal, ReadWorktreeMarker, CanonicalMarkerRoot), so cliworktree importing internal/cli here would close an import cycle (cli -> cliworktree -> cli). BLOCKER: this indirection is a stopgap, not a design decision - the task briefing for this slice assumed internal/composition already imported internal/cli (false, verified) and did not anticipate this specific cycle. Flagged for follow-up: a real fix likely needs repositorySessionStorePath's non-worktree config-resolution logic split out of chat_repository_binding.go so cliworktree can depend on it directly without pulling in the rest of that file's worktree-session-binding logic.
Functions ¶
func AddWorktreeRecoveryRows ¶
func AddWorktreeRecoveryRows(list []vcs.WorktreeInfo, infos []contextstate.WorktreeInstanceInfo) []vcs.WorktreeInfo
AddWorktreeRecoveryRows implements add worktree recovery rows.
func AdoptManagedWorktree ¶
func AdoptManagedWorktree(root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
func BeginManagedWorktreeRemoval ¶
func BeginManagedWorktreeRemoval(root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
func BeginManagedWorktreeRemovalForSession ¶
func BeginManagedWorktreeRemovalForSession(sess *chat.Session, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
func BeginManagedWorktreeRemovalForSessionExpected ¶
func BeginManagedWorktreeRemovalForSessionExpected(sess *chat.Session, root string, wt *vcs.WorktreeInfo, expected contextstate.WorktreeInstance, requireExpected bool) (contextstate.WorktreeInstance, error)
BeginManagedWorktreeRemovalForSessionExpected is relocated from internal/legacytui/worktree_dialog.go: it is pure business logic with no TUI dependency, needed unqualified there and here.
func BeginManagedWorktreeRemovalInStore ¶
func BeginManagedWorktreeRemovalInStore(store *storage.SQLite, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
func BeginManagedWorktreeRemovalInStoreExpected ¶
func BeginManagedWorktreeRemovalInStoreExpected(store *storage.SQLite, root string, wt *vcs.WorktreeInfo, expected contextstate.WorktreeInstance, requireExpected bool) (contextstate.WorktreeInstance, error)
BeginManagedWorktreeRemovalInStoreExpected implements begin managed worktree removal in store expected.
func CanonicalMarkerRoot ¶
func ClassifyMissingWorktreeMarker ¶
func ClassifyMissingWorktreeMarker(store *storage.SQLite, principal contextstate.Principal, worktree, canonicalPath string) (contextstate.WorktreeInstanceInfo, bool, error)
ClassifyMissingWorktreeMarker implements classify missing worktree marker.
func CleanupStaleWorktreeRows ¶
func CleanupStaleWorktreeRows(store *storage.SQLite, principal contextstate.Principal, name string) (bool, error)
CleanupStaleWorktreeRows fences and removes every storage row for one worktree name, tombstoning its sessions. It reports whether any row existed. Call it only when the physical worktree is gone: the name owns at most one non-deleted instance, so a same-name replacement is never touched.
func CreateManagedWorktree ¶
func CreateManagedWorktree(root, name, baseRef, branchPrefix string) (*vcs.WorktreeInfo, error)
CreateManagedWorktree reserves lifecycle state before it creates Git state. A retry completes a retained creation with the same instance ID.
func CreateManagedWorktreeInStoreLocked ¶
func CreateManagedWorktreeInStoreLocked(store *storage.SQLite, root, name, baseRef, branchPrefix string, result *contextstate.WorktreeInstance, lease *os.File) (*vcs.WorktreeInfo, error)
CreateManagedWorktreeInStoreLocked implements create managed worktree in store locked.
func CreateManagedWorktreeInStoreWithInstance ¶
func CreateManagedWorktreeInStoreWithInstance(store *storage.SQLite, root, name, baseRef, branchPrefix string, result *contextstate.WorktreeInstance) (*vcs.WorktreeInfo, error)
CreateManagedWorktreeInStoreWithInstance creates a managed worktree in store and records the resulting instance in result. Relocated from internal/legacytui/worktree_dialog_create.go: it is pure business logic with no TUI dependency, needed unqualified there and here.
func FinishManagedWorktreeRemoval ¶
func FinishManagedWorktreeRemoval(root string, instance contextstate.WorktreeInstance) error
FinishManagedWorktreeRemoval implements finish managed worktree removal.
func FinishManagedWorktreeRemovalInStore ¶
func FinishManagedWorktreeRemovalInStore(store *storage.SQLite, root string, instance contextstate.WorktreeInstance) error
FinishManagedWorktreeRemovalInStore implements finish managed worktree removal in store.
func LockWorktreeLifecycle ¶
LockWorktreeLifecycle implements lock worktree lifecycle.
func LockWorktreeMarkerFile ¶
func ReactivateManagedWorktree ¶
func ReactivateManagedWorktree(root string, instance contextstate.WorktreeInstance) error
ReactivateManagedWorktree implements reactivate managed worktree.
func ReactivateManagedWorktreeInStore ¶
func ReactivateManagedWorktreeInStore(store *storage.SQLite, root string, instance contextstate.WorktreeInstance) error
ReactivateManagedWorktreeInStore implements reactivate managed worktree in store.
func ReadMarkerAtCanonicalRoot ¶
func ReadMarkerAtCanonicalRoot(root string) (contextstate.WorktreeInstance, string, error)
func ReadWorktreeMarker ¶
func ReadWorktreeMarker(root string) (contextstate.WorktreeInstance, error)
ReadWorktreeMarker implements read worktree marker.
func RecoverManagedWorktreeCreationInStore ¶
func RecoverManagedWorktreeCreationInStore(store *storage.SQLite, root string, info contextstate.WorktreeInstanceInfo) (*vcs.WorktreeInfo, error)
RecoverManagedWorktreeCreationInStore implements recover managed worktree creation in store.
func RecoverManagedWorktreeRemovalInfoInStoreLocked ¶
func RecoverManagedWorktreeRemovalInfoInStoreLocked(store *storage.SQLite, root string, info contextstate.WorktreeInstanceInfo, branchPrefix string, lease *os.File) error
RecoverManagedWorktreeRemovalInfoInStoreLocked implements recover managed worktree removal info in store locked.
func RegisterManagedWorktreeInStore ¶
func RegisterManagedWorktreeInStore(store *storage.SQLite, root string, wt *vcs.WorktreeInfo) (contextstate.WorktreeInstance, error)
func RegisterWorktreeRoute ¶
func RegisterWorktreeRoute(root string, wt *vcs.WorktreeInfo) error
RegisterWorktreeRoute creates the route shown in /sessions for a worktree.
func RemoveUnmanagedWorktree ¶
func RemoveUnmanagedWorktree(root string, wt *vcs.WorktreeInfo, branchPrefix string, lease *os.File) error
RemoveUnmanagedWorktree removes a worktree that has no valid lifecycle binding. It removes the physical worktree first so HDD space is always freed, then prunes stale Git metadata and cleans storage rows for the name.
func RemoveWorktreeLocked ¶
RemoveWorktreeLocked removes one worktree by name under an acquired lifecycle lock. It runs deletion recovery, the managed removal, the unmanaged fallback for worktrees without a storage binding, and ghost cleanup for names whose Git worktree is gone. It reports whether the worktree or its storage rows were removed.
func RemoveWorktreeRoute ¶
RemoveWorktreeRoute removes the route after Git has removed its worktree.
func SnapshotWorktreeDialogBindings ¶
func SnapshotWorktreeDialogBindings(store *storage.SQLite, principal contextstate.Principal, worktrees []vcs.WorktreeInfo, recoveries []contextstate.WorktreeInstanceInfo) map[string]WorktreeDialogBinding
SnapshotWorktreeDialogBindings implements snapshot worktree dialog bindings.
func ValidateExpectedWorktreeInstanceInStore ¶
func ValidateExpectedWorktreeInstanceInStore(store *storage.SQLite, root, dir string, expected contextstate.WorktreeInstance) error
ValidateExpectedWorktreeInstanceInStore implements validate expected worktree instance in store.
func WorktreeContainsCurrentDir ¶
WorktreeContainsCurrentDir implements worktree contains current dir.
func WorktreeMarkerPath ¶
func WorktreeRecoveryLabel ¶
func WorktreeRecoveryLabel(state contextstate.WorktreeInstanceState) string
WorktreeRecoveryLabel implements worktree recovery label.
func WorktreeRoutePrincipal ¶
func WorktreeRoutePrincipal(root string) (contextstate.Principal, error)
WorktreeRoutePrincipal implements worktree route principal.
func WriteWorktreeList ¶
func WriteWorktreeList(stdout io.Writer, worktrees []vcs.WorktreeInfo, deleting []contextstate.WorktreeInstanceInfo)
func WriteWorktreeMarker ¶
func WriteWorktreeMarker(root string, instance contextstate.WorktreeInstance) error
Types ¶
type WorktreeDialogBinding ¶
type WorktreeDialogBinding struct {
Instance contextstate.WorktreeInstance
Err error
}
WorktreeDialogBinding holds worktree dialog binding state.
func SnapshotWorktreeDialogBinding ¶
func SnapshotWorktreeDialogBinding(store *storage.SQLite, principal contextstate.Principal, worktree vcs.WorktreeInfo) WorktreeDialogBinding
type WorktreeRecoveryRow ¶
type WorktreeRecoveryRow struct {
Info contextstate.WorktreeInstanceInfo
}
WorktreeRecoveryRow holds worktree recovery row state.
Source Files
¶
- context_setup.go
- worktree_command.go
- worktree_dialog_open.go
- worktree_dialog_recovery.go
- worktree_dialog_switch.go
- worktree_lifecycle_lock.go
- worktree_lifecycle_lock_unix.go
- worktree_lifecycle_recovery.go
- worktree_marker.go
- worktree_marker_lock_open_unix.go
- worktree_marker_lock_unix.go
- worktree_marker_open_unix.go
- worktree_removal.go