worktree

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package worktree provides worktree management operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles worktree CRUD operations.

func NewManager

func NewManager(repoRoot string) *Manager

NewManager creates a new worktree manager.

func (*Manager) Create

func (m *Manager) Create(name string, baseSnapshotID *model.SnapshotID) (*model.WorktreeConfig, error)

Create creates a new worktree with the given name.

func (*Manager) CreateFromSnapshot

func (m *Manager) CreateFromSnapshot(name string, snapshotID model.SnapshotID, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)

CreateFromSnapshot creates a new worktree with content cloned from a snapshot. This is similar to Fork but uses "create" semantics (for the --from flag).

func (*Manager) CreateStartedFromSnapshot

func (m *Manager) CreateStartedFromSnapshot(name string, snapshotID model.SnapshotID, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)

CreateStartedFromSnapshot creates a new workspace whose files come from a save point, without inheriting that save point as workspace history.

func (*Manager) Fork

func (m *Manager) Fork(snapshotID model.SnapshotID, name string, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)

Fork creates a new worktree from a snapshot with content cloned. The new worktree will be at HEAD state (can create snapshots immediately).

func (*Manager) Get

func (m *Manager) Get(name string) (*model.WorktreeConfig, error)

Get returns the config for a specific worktree.

func (*Manager) List

func (m *Manager) List() ([]*model.WorktreeConfig, error)

List returns all worktrees.

func (*Manager) Path

func (m *Manager) Path(name string) (string, error)

Path returns the validated payload path for a worktree.

func (*Manager) PlannedStartedFromPath

func (m *Manager) PlannedStartedFromPath(name string) (string, error)

PlannedStartedFromPath returns the workspace folder that CreateStartedFromSnapshot would publish, without creating staging, payload, or metadata paths.

func (*Manager) RebindRealPath

func (m *Manager) RebindRealPath(name, realPath string) error

RebindRealPath updates the workspace's destination-local real path after the caller has determined that the new binding is safe.

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove deletes a worktree. Fails if the worktree is main.

func (*Manager) Rename

func (m *Manager) Rename(oldName, newName string) error

Rename renames a worktree.

func (*Manager) SetLatest

func (m *Manager) SetLatest(name string, snapshotID model.SnapshotID) error

SetLatest updates both head and latest snapshot IDs for a worktree. This is used by snapshot creation to mark a new latest state.

func (*Manager) UpdateHead

func (m *Manager) UpdateHead(name string, snapshotID model.SnapshotID) error

UpdateHead atomically updates the head snapshot ID for a worktree. This is used by restore to move to a different point in history.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL