gitwt

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 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 gitwt reads worktree information from Git itself. It never creates, moves or removes worktrees — that is the job of Git or Worktrunk.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRepo = errors.New("not inside a git worktree")

Functions

func AdminIDFromGitDir

func AdminIDFromGitDir(commonDir, gitDir string) string

AdminIDFromGitDir maps a worktree's git dir to its admin id.

Types

type Repo

type Repo struct {
	CommonDir    string // absolute git common dir (shared by all worktrees)
	MainPath     string // main worktree path ("" for bare repositories)
	TopLevel     string // top level of the worktree that contained the query path
	CurrentAdmin string // admin id of that worktree
}

Repo describes the repository a path belongs to.

func Resolve

func Resolve(ctx context.Context, dir string) (*Repo, error)

Resolve finds the repository and worktree containing dir.

type Worktree

type Worktree struct {
	Path     string // absolute, symlinks resolved
	Head     string
	Branch   string // short name, "" when detached
	Detached bool
	Bare     bool
	Locked   bool
	Prunable bool
	IsMain   bool
	// AdminID is the name of the directory under <common-dir>/worktrees that
	// Git uses for this worktree. It survives `git worktree move`. It is "."
	// for the main worktree.
	AdminID string
}

Worktree is one entry of `git worktree list --porcelain`, enriched with the stable admin-dir identity.

func List

func List(ctx context.Context, dir string) ([]Worktree, error)

List returns all worktrees of the repository containing dir.

func ParsePorcelain

func ParsePorcelain(out string) []Worktree

ParsePorcelain parses `git worktree list --porcelain` output. The first entry is always the main worktree.

Jump to

Keyboard shortcuts

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