git

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 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 git is a typed wrapper around the git command line. It shells out through pkg/exec; go-git is deliberately not used so behaviour matches the user's git exactly (hooks, config, worktrees, signing).

Index

Constants

View Source
const DefaultLockRetryBudget = 2 * time.Second

DefaultLockRetryBudget is how long git commands wait for a held index lock before giving up. IDEs and agents take the lock for milliseconds at a time while refreshing status, which is plenty to make a bare `git add` fail.

Variables

View Source
var ErrDetached = errors.New("HEAD is detached")

ErrDetached is returned when HEAD is not on a branch.

View Source
var ErrIndexLocked = errors.New("the index is locked by another git process")

ErrIndexLocked matches the error git commands return when another process held a worktree's index lock (index.lock) for longer than the retry budget. git-stack never removes a lock itself.

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

ErrNotRepo is returned by Discover outside a git repository.

View Source
var ErrRefLocked = errors.New("a ref is locked by another git process")

ErrRefLocked matches a command that failed because another process held a ref's lock file (refs/heads/main.lock, packed-refs.lock).

Functions

func LockPath added in v0.2.0

func LockPath(err error) string

LockPath is the lock file a command failed on (ErrIndexLocked or ErrRefLocked), or "".

Types

type AddMode

type AddMode int

AddMode selects what `git add` stages.

const (
	// AddNone stages nothing.
	AddNone AddMode = iota
	// AddAll stages all changes including untracked files (git add -A).
	AddAll
	// AddUpdate stages changes to tracked files only (git add -u).
	AddUpdate
	// AddPatch stages hunks interactively (git add -p); needs a TTY.
	AddPatch
)

type Branch

type Branch struct {
	Name string
	// Head is the tip commit id.
	Head string
	// CommitTime is the committer date of the tip.
	CommitTime time.Time
	// Worktree is the path of the worktree the branch is checked out in, or
	// empty.
	Worktree string
	// Upstream is the tracking branch (e.g. origin/feat), or empty.
	Upstream string
}

Branch describes a local branch.

type Client

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

Client runs git commands.

func New

func New(r exec.Runner, opts ...Option) *Client

New returns a Client that runs git through r.

func (*Client) Add

func (c *Client) Add(ctx context.Context, repo Repo, mode AddMode) error

Add stages changes according to mode.

func (*Client) AddedPaths added in v0.1.4

func (c *Client) AddedPaths(ctx context.Context, repo Repo, from, to string) ([]string, error)

AddedPaths lists the paths that exist in to's tree but not in from's.

func (*Client) BranchExists

func (c *Client) BranchExists(ctx context.Context, repo Repo, name string) (bool, error)

BranchExists reports whether a local branch exists.

func (*Client) Branches

func (c *Client) Branches(ctx context.Context, repo Repo) ([]Branch, error)

Branches lists local branches sorted by name.

func (*Client) ChangedFiles added in v0.2.0

func (c *Client) ChangedFiles(ctx context.Context, repo Repo) ([]string, error)

ChangedFiles lists tracked files with staged or unstaged changes in the worktree at repo, relative to it. It reads with --no-optional-locks, as it may look at another worktree.

func (*Client) ChangedPaths added in v0.1.5

func (c *Client) ChangedPaths(ctx context.Context, repo Repo, from, to string) ([]string, error)

ChangedPaths lists the paths whose content differs between the trees of from and to.

func (*Client) CheckRefFormat

func (c *Client) CheckRefFormat(ctx context.Context, name string) error

CheckRefFormat validates name as a branch name.

func (*Client) Commit

func (c *Client) Commit(ctx context.Context, repo Repo, o CommitOptions) (string, error)

Commit creates or amends a commit and returns the new HEAD id. When the editor must open (no message and not NoEdit, or Edit), the command runs in passthrough mode.

func (*Client) CommitInfo added in v0.1.4

func (c *Client) CommitInfo(ctx context.Context, repo Repo, rev string) (CommitInfo, error)

CommitInfo reads rev's author, message, tree and first parent.

func (*Client) CommitTree added in v0.1.4

func (c *Client) CommitTree(ctx context.Context, repo Repo, tree, parent string, info CommitInfo) (string, error)

CommitTree creates a commit of tree on parent with info's author, author date and message. The committer is the current user. The commit is not signed: unlike commit and rebase, commit-tree ignores commit.gpgsign and only signs when asked with -S, which we don't pass, so a replay never needs the signing key.

func (*Client) Commits added in v0.2.0

func (c *Client) Commits(ctx context.Context, repo Repo, tip string, exclude ...string) ([]Commit, error)

Commits lists the commits reachable from tip but from none of exclude, newest first. Revisions that don't resolve (a deleted parent branch, a recorded base that was garbage collected) are ignored rather than failing the read, and a missing tip lists nothing. It's a read that can run while another git process works in any worktree, so it takes no optional locks, and the output is NUL separated since a subject can hold anything.

func (*Client) ConfigAdd

func (c *Client) ConfigAdd(ctx context.Context, repo Repo, scope Scope, key, value string) error

ConfigAdd appends a value to a multi-valued key.

func (*Client) ConfigGet

func (c *Client) ConfigGet(ctx context.Context, repo Repo, scope Scope, key string) (string, bool, error)

ConfigGet returns the value of key. The boolean reports whether it was set.

func (*Client) ConfigGetAll

func (c *Client) ConfigGetAll(ctx context.Context, repo Repo, scope Scope, key string) ([]string, error)

ConfigGetAll returns every value of a multi-valued key.

func (*Client) ConfigGetRegexp

func (c *Client) ConfigGetRegexp(ctx context.Context, repo Repo, scope Scope, re string) ([]ConfigEntry, error)

ConfigGetRegexp returns every entry whose key matches the regexp.

func (*Client) ConfigSet

func (c *Client) ConfigSet(ctx context.Context, repo Repo, scope Scope, key, value string) error

ConfigSet sets key to value, replacing existing values.

func (*Client) ConfigUnset

func (c *Client) ConfigUnset(ctx context.Context, repo Repo, scope Scope, key string) error

ConfigUnset removes every value of key. A missing key is not an error.

func (*Client) ConfigUnsetValue

func (c *Client) ConfigUnsetValue(ctx context.Context, repo Repo, scope Scope, key, value string) error

ConfigUnsetValue removes the values of key that match the given value (exact match). A missing key or value is not an error.

func (*Client) ConflictedFiles

func (c *Client) ConflictedFiles(ctx context.Context, repo Repo) ([]string, error)

ConflictedFiles lists paths with unresolved merge conflicts.

func (*Client) CountCommits

func (c *Client) CountCommits(ctx context.Context, repo Repo, from, to string) (int, error)

CountCommits returns the number of commits in from..to.

func (*Client) CreateBranch

func (c *Client) CreateBranch(ctx context.Context, repo Repo, name, start string) error

CreateBranch creates name at start without checking it out.

func (*Client) CurrentBranch

func (c *Client) CurrentBranch(ctx context.Context, repo Repo) (string, error)

CurrentBranch returns the checked-out branch name.

func (*Client) DefaultBranch

func (c *Client) DefaultBranch(ctx context.Context, repo Repo) (string, bool, error)

DefaultBranch guesses the repository's trunk the way gh-stack does: the branch origin/HEAD points at, else a local main or master. The boolean is false when nothing matches.

func (*Client) DeleteBranch added in v0.1.4

func (c *Client) DeleteBranch(ctx context.Context, repo Repo, name string) error

DeleteBranch deletes a local branch whether or not it is merged. git refuses when the branch is checked out in any worktree; callers check.

func (*Client) DeleteRemoteBranch added in v0.4.0

func (c *Client) DeleteRemoteBranch(ctx context.Context, repo Repo, remote, branch, expect string) error

DeleteRemoteBranch deletes branch on remote. With expect set, the delete is leased against it, so a branch that has moved on the remote since is refused rather than deleted; with it empty the branch is deleted whatever its tip.

func (*Client) DiffCommit added in v0.3.0

func (c *Client) DiffCommit(ctx context.Context, repo Repo, rev string) (string, error)

DiffCommit returns rev's changes against its first parent as a zero context diff with renames detected.

func (*Client) DiffRange

func (c *Client) DiffRange(ctx context.Context, repo Repo, base, head string) (string, error)

DiffRange returns the diff between base and head (base...head semantics are not used: this is the exact tree difference, which is what a rebased branch shows against its parent).

func (*Client) Discover

func (c *Client) Discover(ctx context.Context, dir string) (Repo, error)

Discover resolves the repository containing dir.

func (*Client) EmptyTreeCommit added in v0.4.0

func (c *Client) EmptyTreeCommit(ctx context.Context, repo Repo, parents []string, msg string) (string, error)

EmptyTreeCommit creates a commit with an empty tree and the given parents. Nothing ever checks it out; a ref pointing at it keeps every parent from being garbage collected.

func (*Client) Fetch added in v0.1.4

func (c *Client) Fetch(ctx context.Context, repo Repo, remote string) error

Fetch updates the remote-tracking refs of remote and prunes the ones whose branch is gone. Nothing local moves.

func (*Client) HasMerges added in v0.3.0

func (c *Client) HasMerges(ctx context.Context, repo Repo, from, to string) (bool, error)

HasMerges reports whether from..to holds a merge commit.

func (*Client) HasStagedChanges

func (c *Client) HasStagedChanges(ctx context.Context, repo Repo) (bool, error)

HasStagedChanges reports whether the index differs from HEAD. Like every read that may run against another worktree, it passes --no-optional-locks so it never takes (or trips over) that worktree's index lock just to refresh stat data.

func (*Client) HasUnstagedChanges

func (c *Client) HasUnstagedChanges(ctx context.Context, repo Repo) (bool, error)

HasUnstagedChanges reports whether the working tree has unstaged changes to tracked files.

func (*Client) HasUntrackedFiles

func (c *Client) HasUntrackedFiles(ctx context.Context, repo Repo) (bool, error)

HasUntrackedFiles reports whether untracked, non-ignored files exist.

func (*Client) IndexLockPath added in v0.2.0

func (c *Client) IndexLockPath(ctx context.Context, repo Repo) (string, error)

IndexLockPath is where git keeps the index lock for the worktree at repo: .git/index.lock for the main one, .git/worktrees/<name>/index.lock for a linked one. It only names the file; nothing here ever removes it.

func (*Client) IsAncestor

func (c *Client) IsAncestor(ctx context.Context, repo Repo, ancestor, descendant string) (bool, error)

IsAncestor reports whether ancestor is reachable from descendant.

func (*Client) ListCmds

func (c *Client) ListCmds(ctx context.Context, spec string) ([]string, error)

ListCmds returns `git --list-cmds=<spec>` (e.g. "builtins" or "main,others").

func (*Client) LocalChanges added in v0.1.5

func (c *Client) LocalChanges(ctx context.Context, repo Repo) ([]string, error)

LocalChanges lists the paths whose index or working tree content differs from HEAD, relative to the top level. Untracked files are not included; Untracked lists those.

func (*Client) MergeBase added in v0.1.4

func (c *Client) MergeBase(ctx context.Context, repo Repo, a, b string) (string, error)

MergeBase returns the best common ancestor of a and b.

func (*Client) MergeFF added in v0.1.4

func (c *Client) MergeFF(ctx context.Context, repo Repo, rev string) error

MergeFF fast forwards the branch checked out in repo's worktree to rev and updates the tree. It refuses, changing nothing, when rev is not a descendant or a dirty file would be overwritten.

func (*Client) MergeTree added in v0.1.4

func (c *Client) MergeTree(ctx context.Context, repo Repo, base, ours, theirs string) (MergeTreeResult, error)

MergeTree merges ours and theirs with base as the common ancestor.

func (*Client) Messages

func (c *Client) Messages(ctx context.Context, repo Repo, from, to string) ([]string, error)

Messages returns the full commit messages in from..to, oldest first.

func (*Client) Passthrough

func (c *Client) Passthrough(ctx context.Context, repo Repo, args ...string) error

Passthrough runs git with the terminal attached (editors, `add -p`).

func (*Client) PatchIDs added in v0.1.4

func (c *Client) PatchIDs(ctx context.Context, repo Repo, from, to string) (map[string]string, error)

PatchIDs maps the patch id of every non merge commit in from..to to that commit, so two histories can be compared for the same changes regardless of where they were rebased. The ids are verbatim: unlike --stable they count whitespace, so a whitespace only amend is a different change.

func (*Client) PatchIDsExcluding added in v0.1.4

func (c *Client) PatchIDsExcluding(ctx context.Context, repo Repo, to string, exclude ...string) (map[string]string, error)

PatchIDsExcluding is PatchIDs for the commits reachable from to but from none of exclude.

func (*Client) PatchTree added in v0.3.0

func (c *Client) PatchTree(ctx context.Context, repo Repo, tree, patch string) (string, error)

PatchTree applies patch, a zero context diff, to tree and returns the new tree. It goes through a temporary index in the git dir, so the real index and working tree are never touched, and the temporary index is removed whether or not it worked. git checks every removed line against the file (line numbers are only a hint to it), so a patch that doesn't fit comes back as a *PatchError and nothing is written. git also applies a hunk at an offset when it finds the removed lines elsewhere; a correct plan always matches at the stated line, so an offset is refused too. Whitespace settings are ignored so the applied lines are exactly the patch's.

func (*Client) PointHEAD added in v0.4.0

func (c *Client) PointHEAD(ctx context.Context, repo Repo, branch string) error

PointHEAD makes branch the current branch without touching the index or the working tree, so whatever differs from its tip shows as changes. git would happily point HEAD at a branch that doesn't exist, so that is refused first.

func (*Client) PruneWorktrees added in v0.2.3

func (c *Client) PruneWorktrees(ctx context.Context, repo Repo) error

PruneWorktrees forgets every worktree whose directory is gone, the way git worktree prune does. Locked ones are left alone.

func (*Client) Push added in v0.3.0

func (c *Client) Push(ctx context.Context, repo Repo, remote string, leases []PushLease) error

Push force pushes each branch to the same name on remote, all or nothing. Each one is leased against its Expect, so a remote that has moved since the caller looked is refused rather than overwritten.

func (*Client) RebaseAbort added in v0.1.5

func (c *Client) RebaseAbort(ctx context.Context, repo Repo) error

RebaseAbort abandons a rebase in progress; git puts the branch it was rebasing back and checks it out.

func (*Client) RebaseContinue added in v0.1.5

func (c *Client) RebaseContinue(ctx context.Context, repo Repo) (stopped bool, err error)

RebaseContinue resumes a stopped rebase after the conflicts were staged. stopped is true when it stopped again on unresolved conflicts; any other failure is an error.

func (*Client) RebaseInProgress

func (c *Client) RebaseInProgress(ctx context.Context, repo Repo) (bool, error)

RebaseInProgress reports whether git has a rebase in progress.

func (*Client) RebaseMatches added in v0.1.5

func (c *Client) RebaseMatches(ctx context.Context, repo Repo, branch, onto, tip string) (bool, error)

RebaseMatches reports whether the active rebase is for branch, from tip onto onto. Both git rebase backends record these values in the worktree's git dir; a rebase started after an earlier one was aborted can differ in any of them. It only reads the state, leaving the rebase and index alone.

func (*Client) RebaseOnto added in v0.1.5

func (c *Client) RebaseOnto(ctx context.Context, repo Repo, onto, upstream, branch string) (stopped bool, err error)

RebaseOnto runs `git rebase --onto onto upstream branch` without an editor. It checks branch out, so the working tree must be clean enough for git. stopped is true when git stopped on a conflict and left the rebase in progress for the caller to resolve; any other failure is an error.

func (*Client) Reflog added in v0.1.6

func (c *Client) Reflog(ctx context.Context, repo Repo, ref string) ([]string, error)

Reflog lists every commit ref has pointed at that the reflog still remembers, newest first. A ref with no reflog, or no ref at all, gives nothing.

func (*Client) RemoteFor added in v0.1.4

func (c *Client) RemoteFor(ctx context.Context, repo Repo, branch string) string

RemoteFor is the remote a branch tracks (branch.<name>.remote), or origin when it tracks nothing.

func (*Client) RemoteURL added in v0.2.0

func (c *Client) RemoteURL(ctx context.Context, repo Repo, name string) (string, error)

RemoteURL is the URL git uses to fetch from the named remote, with url.<base>.insteadOf rewriting applied (git remote get-url). It only reads config; nothing touches the network.

func (*Client) RenameBranch added in v0.4.0

func (c *Client) RenameBranch(ctx context.Context, repo Repo, from, to string) error

RenameBranch renames a local branch, its reflog and its config (the upstream included, which still names the old remote branch). git refuses when to already exists.

func (*Client) Replay added in v0.1.4

func (c *Client) Replay(ctx context.Context, repo Repo, commits []string, onto string) (ReplayResult, error)

Replay recreates commits, oldest first, on top of onto. It never touches a working tree, the index or a ref: it only creates objects, so the caller decides what to do with Tip. A merge commit is replayed against its first parent, which linearises it. A commit whose changes are already in the new parent would come out empty and is dropped instead. A root commit is replayed with an empty merge base.

func (*Client) ResetHard added in v0.1.4

func (c *Client) ResetHard(ctx context.Context, repo Repo, rev string) error

ResetHard moves the checked out branch, the index and the tree to rev. git deletes an untracked file in the way of a tracked one; callers check with AddedPaths and Untracked first.

func (*Client) ResetKeep added in v0.1.5

func (c *Client) ResetKeep(ctx context.Context, repo Repo, rev string) error

ResetKeep moves HEAD and the checked out branch to rev and updates the working tree, keeping local changes to files rev and HEAD agree on. git refuses, and nothing moves, when a locally changed file differs between the two. Staged new files are re-added afterwards because reset --keep drops them from the index; the caller refuses up front when the move adds the same path, so re-adding cannot clobber anything.

func (*Client) ResetSoft added in v0.4.0

func (c *Client) ResetSoft(ctx context.Context, repo Repo, rev string) error

ResetSoft moves the checked out branch to rev, leaving the index and the working tree alone.

func (*Client) RevList added in v0.1.4

func (c *Client) RevList(ctx context.Context, repo Repo, from, to string) ([]string, error)

RevList lists the commits reachable from to but not from, oldest first.

func (*Client) RevParse

func (c *Client) RevParse(ctx context.Context, repo Repo, rev string) (string, error)

RevParse resolves rev to a full object id.

func (*Client) Runner

func (c *Client) Runner() exec.Runner

Runner exposes the underlying runner (used by adapters that run other tools with the same debug/TTY settings).

func (*Client) StagedDiff

func (c *Client) StagedDiff(ctx context.Context, repo Repo) (string, error)

StagedDiff returns the diff of the index against HEAD.

func (*Client) StagedPatch added in v0.3.0

func (c *Client) StagedPatch(ctx context.Context, repo Repo) (string, error)

StagedPatch returns the index against HEAD the way DiffCommit reads a commit.

func (*Client) Subject

func (c *Client) Subject(ctx context.Context, repo Repo, rev string) (string, error)

Subject returns the first line of the commit message of rev.

func (*Client) Subjects

func (c *Client) Subjects(ctx context.Context, repo Repo, rev string, n int) ([]string, error)

Subjects returns the commit subjects of rev's history, newest first, at most n.

func (*Client) Switch

func (c *Client) Switch(ctx context.Context, repo Repo, name string) error

Switch checks out an existing branch.

func (*Client) SwitchDetached added in v0.1.1

func (c *Client) SwitchDetached(ctx context.Context, repo Repo, rev string) error

SwitchDetached checks out rev with a detached HEAD.

func (*Client) Tip added in v0.1.4

func (c *Client) Tip(ctx context.Context, repo Repo, ref string) (string, bool, error)

Tip resolves a full ref name (refs/heads/x, refs/remotes/origin/x) to a commit id. ok is false when the ref does not exist.

func (*Client) TreeOf added in v0.1.4

func (c *Client) TreeOf(ctx context.Context, repo Repo, rev string) (string, error)

TreeOf returns the tree of the commit rev.

func (*Client) Untracked added in v0.1.4

func (c *Client) Untracked(ctx context.Context, repo Repo) ([]string, error)

Untracked lists the untracked, non ignored files in repo's worktree, relative to its top level.

func (*Client) UpdateRefs added in v0.1.4

func (c *Client) UpdateRefs(ctx context.Context, repo Repo, updates []RefUpdate) error

UpdateRefs applies every update in one transaction: all move or none do.

func (*Client) Worktrees added in v0.1.1

func (c *Client) Worktrees(ctx context.Context, repo Repo) ([]Worktree, error)

Worktrees lists the main checkout and every linked worktree.

type Commit added in v0.2.0

type Commit struct {
	SHA     string
	Subject string
}

Commit is a commit as a list shows it: its id and subject.

type CommitInfo added in v0.1.4

type CommitInfo struct {
	Author, Email string
	// Date is the author date in strict ISO 8601 (git's %aI).
	Date    string
	Message string
	Tree    string
	// Parent is the first parent, "" for a root commit.
	Parent string
}

CommitInfo is what it takes to recreate a commit somewhere else.

type CommitOptions

type CommitOptions struct {
	// Message paragraphs; each becomes a -m argument. Empty opens the editor
	// unless NoEdit is set.
	Message []string
	Amend   bool
	NoEdit  bool
	// Edit forces the editor even with a message (or when amending).
	Edit        bool
	ResetAuthor bool
	NoVerify    bool
	// AllowEmpty permits a commit with no changes.
	AllowEmpty bool
}

CommitOptions controls Commit.

type ConfigEntry

type ConfigEntry struct {
	Key   string
	Value string
}

ConfigEntry is one key/value pair.

type Conflict added in v0.1.4

type Conflict struct {
	Commit string
	Files  []string
}

Conflict is a commit that could not be replayed cleanly.

type MergeTreeResult added in v0.1.4

type MergeTreeResult struct {
	Tree      string
	Conflicts []string
}

MergeTreeResult is a three way merge computed without a working tree: the merged tree, and the conflicting paths when it was not clean (the tree then contains conflict markers and must not be committed).

type Option

type Option func(*Client)

Option configures a Client.

func WithLockRetry

func WithLockRetry(budget time.Duration, sleep func(context.Context, time.Duration) error) Option

WithLockRetry sets the retry budget for a held index lock and the function used to wait between attempts (tests pass a fake).

type OverwriteError added in v0.2.0

type OverwriteError struct {
	Changed, Untracked []string
}

OverwriteError is git refusing to move a checkout because doing so would overwrite files in it: local changes to tracked files (Changed) and untracked files where the update writes (Untracked). Paths are relative to the checkout. git touched nothing.

func (*OverwriteError) Error added in v0.2.0

func (e *OverwriteError) Error() string

type PatchError added in v0.3.0

type PatchError struct {
	Detail string
}

PatchError is a patch git apply would not put on the tree as given: the lines it removes are not where it says, it applied them at an offset, or git rejected it for any other reason. Detail is git's output.

func (*PatchError) Error added in v0.3.0

func (e *PatchError) Error() string

type PushLease added in v0.3.0

type PushLease struct {
	Branch string
	Expect string
}

PushLease is a branch to push and the remote tip it may replace. An empty Expect means the branch must not exist on the remote yet.

type RefUpdate added in v0.1.4

type RefUpdate struct {
	Ref, New, Old string
}

RefUpdate moves Ref to New, or deletes it when New is empty. When Old is set the ref must currently be at Old, and the whole transaction fails if any Old is stale.

type ReplayResult added in v0.1.4

type ReplayResult struct {
	// Tip is the new tip (onto itself when there was nothing to replay), or
	// "" when Conflict is set.
	Tip string
	// Replayed counts the commits recreated.
	Replayed int
	// Skipped counts the commits dropped because their changes were already
	// in the new parent, as git rebase drops them.
	Skipped int
	// Conflict is set when the replay stopped; the commits before it were
	// recreated as unreferenced objects and nothing else happened.
	Conflict *Conflict
}

ReplayResult is what Replay produced.

type Repo

type Repo struct {
	// TopLevel is the working tree root.
	TopLevel string
	// GitDir is the repository directory for this worktree
	// (e.g. .git or .git/worktrees/<name>).
	GitDir string
	// CommonDir is the shared repository directory (.git of the main worktree).
	CommonDir string
}

Repo locates a repository. All paths are absolute.

func (Repo) IsLinkedWorktree

func (r Repo) IsLinkedWorktree() bool

IsLinkedWorktree reports whether the repo is a linked worktree.

type Scope

type Scope int

Scope selects which git config file an operation targets.

const (
	// ScopeMerged reads the effective value across all files (reads only).
	ScopeMerged Scope = iota
	// ScopeGlobal targets the user's global config.
	ScopeGlobal
	// ScopeLocal targets the repository config.
	ScopeLocal
)

type SigningError added in v0.2.2

type SigningError struct {
	// Format is gpg.format: ssh, openpgp (the default) or x509.
	Format string
	// Key is user.signingkey as configured, which for ssh is usually the
	// path of the public key file; empty when unset.
	Key string
	// Detail is git's stderr, including the signing program's output.
	Detail string
}

SigningError reports that git could not sign a commit. Nothing was committed. From Commit the index is untouched; from a rebase (RebaseOnto, RebaseContinue) the rebase is left in progress with the failed pick's changes staged, for RebaseContinue to commit once signing works or RebaseAbort to drop.

func (*SigningError) Error added in v0.2.2

func (e *SigningError) Error() string

type Worktree added in v0.1.1

type Worktree struct {
	// Path is the working tree root.
	Path string
	Head string
	// Branch is the checked out branch (short name), empty when detached or bare.
	Branch   string
	Detached bool
	Bare     bool
	// Prunable is set when git would prune the entry, usually because its
	// directory has been deleted.
	Prunable bool
	// Locked is set when the entry is locked against pruning.
	Locked bool
}

Worktree is one entry of `git worktree list`.

Directories

Path Synopsis
Package gittest creates isolated temporary repositories for tests.
Package gittest creates isolated temporary repositories for tests.

Jump to

Keyboard shortcuts

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