git

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 20 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 git wraps the system git binary for worktrees, branches and status.

Implemented in P1; see docs/PLAN.md.

Index

Constants

View Source
const MaxDiffBytes = 2 << 20

Variables

View Source
var ErrCredentialCanceled = errors.New("git authentication canceled")

Functions

func Commits added in v0.0.5

func Commits(ctx context.Context, path, base string) (string, error)

func Context added in v0.0.2

func Context(ctx context.Context, path, base string) (string, error)
func Head(ctx context.Context, path string) (string, error)

func PromptCredential added in v1.0.0

func PromptCredential(ctx context.Context, prompt string) (string, error)

PromptCredential forwards an IPC credential challenge to the current caller.

func Push added in v0.0.5

func Push(ctx context.Context, path, branch string) error

func RunAskpass added in v0.0.6

func RunAskpass(args []string, out io.Writer) (handled bool, code int)

RunAskpass handles invocations of this executable by Git or OpenSSH. Secrets travel over a temporary loopback connection, never arguments or files.

func WithCredentialPrompt added in v0.0.6

func WithCredentialPrompt(ctx context.Context, prompt CredentialPrompt) context.Context

WithCredentialPrompt routes Git and SSH askpass requests to the caller.

Types

type CredentialPrompt added in v0.0.6

type CredentialPrompt func(context.Context, string) (string, error)

type DiffResult added in v0.0.5

type DiffResult struct {
	Patch     string
	Untracked string
	Truncated bool
}

DiffResult compares the base commit with the tracked working tree, including both staged and unstaged edits. Untracked paths are listed separately.

func WorktreeDiff added in v0.0.5

func WorktreeDiff(ctx context.Context, path, base string) (DiffResult, error)

type Repo

type Repo struct{ Root, CommonDir, Remote, DefaultBranch string }

func Discover

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

Discover resolves linked worktrees to the main checkout, so all tabs in the same repository share a project identity and lock.

func (Repo) CheckpointCommitted added in v1.0.0

func (r Repo) CheckpointCommitted(ctx context.Context, path string, c portable.Checkpoint) error

func (Repo) CleanupCheck added in v0.0.5

func (r Repo) CleanupCheck(ctx context.Context, path, branch, base, mergedHead string) error

CleanupCheck checks against the actual remote branch, rather than a potentially stale upstream tracking ref. A merged PR's exact head is also proof of upload.

func (Repo) Commit added in v1.0.0

func (r Repo) Commit(ctx context.Context, ref string) (string, error)

func (Repo) CreateWorktree

func (r Repo) CreateWorktree(ctx context.Context, spec WorktreeSpec) error

func (Repo) EnablePortable added in v1.0.0

func (r Repo) EnablePortable(worktree string) error

EnablePortable replaces only Maestro's exact generated legacy ignore block. Legacy custom-agent files remain ignored; only checkpoint paths are exposed.

func (Repo) FinishCleanup added in v0.0.5

func (r Repo) FinishCleanup(ctx context.Context, branch string, id int64, force bool, mergedHead string) error

FinishCleanup resumes a removal interrupted between Git and SQLite updates.

func (Repo) HasCheckpoint added in v1.0.0

func (r Repo) HasCheckpoint(ctx context.Context, tip string, c portable.Checkpoint) bool

HasCheckpoint proves checkpoint ancestry from published file history, not from a local code commit that may predate an unpublished checkpoint.

func (Repo) IsAncestor added in v1.0.0

func (r Repo) IsAncestor(ctx context.Context, before, after string) bool

func (Repo) Key

func (r Repo) Key() string

Key avoids collisions between checkouts with the same directory name.

func (Repo) PRBase added in v0.0.5

func (r Repo) PRBase(ctx context.Context, base string) (string, error)

PRBase resolves named local/remote bases; commit-only tasks must supply a base.

func (Repo) PreserveHead added in v0.0.5

func (r Repo) PreserveHead(ctx context.Context, path string, id int64) (string, error)

PreserveHead protects the local commits from garbage collection even after a squash merge, force cleanup, or deletion of the remote task branch.

func (Repo) ProvisionWorktree added in v0.0.5

func (r Repo) ProvisionWorktree(ctx context.Context, spec WorktreeSpec, start int, advance func(int) error) error

ProvisionWorktree resumes copies/setup at start. advance persists the next step after each success. Failed setup retains the worktree for inspection.

func (Repo) RecreateWorktree added in v0.0.5

func (r Repo) RecreateWorktree(ctx context.Context, path, branch, commit string) error

func (Repo) RemoveWorktree added in v0.0.5

func (r Repo) RemoveWorktree(ctx context.Context, path, branch, head string, force, merged bool) error

func (Repo) RestoreWorktree added in v1.0.0

func (r Repo) RestoreWorktree(ctx context.Context, path, branch, commit, ref string) error

RestoreWorktree attaches an existing branch or creates it from the fetched commit. Never resets branches or runs repository setup commands on discovery.

func (Repo) StableBase added in v0.0.5

func (r Repo) StableBase(ctx context.Context, base string) (string, error)

StableBase keeps named branches usable as comparison targets, while resolving checkout-relative revisions such as HEAD and HEAD~1 in the source checkout.

func (Repo) TaskCheckpoints added in v1.0.0

func (r Repo) TaskCheckpoints(ctx context.Context, only string) ([]TaskCheckpoint, error)

TaskCheckpoints only reads fetched/local branch tips, never contacting remotes. A manifest inherited by another branch is not that branch's task.

func (Repo) TaskWorktree added in v1.0.0

func (r Repo) TaskWorktree(ctx context.Context, branch string) (string, error)

TaskWorktree returns an existing checkout for this branch, including the main checkout. Destructive cleanup continues to require ValidateWorktree.

func (Repo) ValidateTaskCheckout added in v1.0.0

func (r Repo) ValidateTaskCheckout(ctx context.Context, path, branch string) error

func (Repo) ValidateWorktree added in v0.0.5

func (r Repo) ValidateWorktree(ctx context.Context, path, branch string) error

type Status

type Status struct {
	Dirty, Added, Deleted, Ahead, Behind, Commits int
	Upstream                                      bool
}

func WorktreeStatus

func WorktreeStatus(ctx context.Context, path, base string) (Status, error)

type TaskCheckpoint added in v1.0.0

type TaskCheckpoint struct {
	portable.Checkpoint
	Ref, Commit string
}

type WorktreeSpec

type WorktreeSpec struct {
	Path, Branch, Base string
	Copy, Setup        []string
}

Jump to

Keyboard shortcuts

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