worktree

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package worktree gives work its own git worktree, so it can change files without touching the checkout the user works in (spec_parity_027 §8.2): <repo>/.blitz/worktrees/<name> on the branch blitz/<name>, from HEAD or another ref, with the untracked files .worktreeinclude lists (a .env, say) copied in.

Index

Constants

View Source
const BranchPrefix = "blitz/"

BranchPrefix names their branches.

View Source
const Dir = ".blitz/worktrees"

Dir is where worktrees go, under the repository's root.

View Source
const IncludeFile = ".worktreeinclude"

IncludeFile lists, one pattern a line, untracked files to copy into a new worktree.

Variables

View Source
var ErrNotRepo = errors.New("not in a git repository")

ErrNotRepo means the directory isn't in a git repository.

Functions

func Dirty

func Dirty(w Worktree) bool

Dirty reports whether w has changes to tracked files not committed (untracked files, such as those copied in, don't count).

func NewName

func NewName(prefix string) string

NewName is a name for a worktree: prefix and the time, with a little randomness.

func Prune

func Prune(dir string) error

Prune forgets worktrees whose folders are gone.

func Root

func Root(dir string) (string, error)

Root is the root of the repository dir is in: the main checkout's, even from inside one of its worktrees.

Types

type Worktree

type Worktree struct {
	Name   string
	Path   string
	Branch string
	// Missing means git knows it, but its directory is gone (prune removes
	// it).
	Missing bool
}

Worktree is one of Blitz's worktrees.

func Create

func Create(dir, name, ref string) (Worktree, error)

Create makes the worktree name (a new name when "") in the repository dir is in, on a new branch blitz/<name> from ref (HEAD when ""), and copies in the files .worktreeinclude lists.

func List

func List(dir string) ([]Worktree, error)

List is the repository's Blitz worktrees (those under .blitz/worktrees).

func Remove

func Remove(dir, name string, force bool) (Worktree, error)

Remove removes worktree name; force removes it with changes not committed. Its branch stays, to merge or delete.

Jump to

Keyboard shortcuts

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