gitread

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 18 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 gitread runs the read-only git commands the release, hooks, and Repo scripts services ask of a clone, and reads their answers: the current branch, uncommitted changes, what git is in the middle of, branches and tags here and on origin, the commits between two, the signing settings, and where the hooks live. Message words their failures for the user.

Every command is checked against an exact allowlist before it runs, and anything else is refused with ErrGitCommandNotAllowed: no command here changes a clone's files, index, refs, or config, or runs a hook, and a status runs with the filter drivers the clone's own config defines turned off, so reading a clone runs no program the clone names. Each runs as `git -C <dir> -c core.fsmonitor=false -c submodule.recurse=false <args>`, with GIT_OPTIONAL_LOCKS=0, so a status never takes the index lock a release might need, and GIT_TERMINAL_PROMPT=0, so git never waits for an answer no one can give. core.hooksPath is left alone: the hooks scan needs the folder it names, and none of these commands runs a hook.

git is the one on the PATH of the environment Config.Env returns, the login shell's in the app, so the checks use the same git, and the same credential helpers, as the tools the user releases with. The ls-remote commands, the only ones that reach origin, stop after RemoteTimeout, and run ssh in batch mode unless the user chose their own ssh command, which can carry an agent such as a password manager's. They run no program the clone's own config names (see remoteGuard): a remote helper is refused, and so is an http or https origin the clone's own config reroutes; only the file, http, https, and ssh transports are allowed; the clone's ssh command, password program, and credential helpers give way to the user's own; no cookie file is written; and origin is asked for git's own upload-pack. No other command reaches a transport at all.

The git commands that do change a clone, run elsewhere, get what they run with from a Setup (RemoteSetup, RemoteSetupFor, CheckoutSetup), which first refuses a clone whose own config holds a setting cloneconfig.go's classes refuse.

Index

Constants

View Source
const (

	// The settings of the clone's own an ls-remote set aside, as SetAsideError names them:
	// its ssh command, password program, and credential helpers.
	SetAsideSSHCommand = "core.sshCommand"
	SetAsideAskPass    = "core.askPass"
	SetAsideHelpers    = helperKey
)
View Source
const MaxDiff = 1 << 20

MaxDiff is the most of a worktree's diff WorktreeDiff returns, in bytes.

View Source
const (

	// RemoteTimeout bounds one ls-remote, the only command that reaches origin.
	RemoteTimeout = 15 * time.Second
)

Variables

View Source
var ErrCloneConfig = errors.New("this clone's own git config sets settings a command that changes it isn't run with")

ErrCloneConfig is returned, inside a CloneConfigError, for a clone whose own git config sets a setting a command that changes the clone isn't run with (cloneSettingAllowed).

View Source
var ErrCloneRoutes = errors.New("this clone's own git config changes how origin is reached, so it isn't asked from here")

ErrCloneRoutes is returned for a clone whose origin is on http or https and whose own config changes how it is reached: whether its certificate is checked and against what, a proxy, or the address its host resolves to (routeKeys). Asked from there, origin could be someone else, handed the user's credentials, cookies, and headers for the real host, so an ls-remote there is refused before it runs.

View Source
var ErrGitCommandNotAllowed = errors.New("git command not allowed")

ErrGitCommandNotAllowed is returned for a git command outside the allowlist, or a folder that is not absolute and clean; it is never run.

View Source
var ErrNoGit = errors.New("git can't be found on the login shell's PATH or in the usual tool folders")

ErrNoGit is returned for a Setup when git can't be found where every gitread command looks for it (GitFinder).

View Source
var ErrRemoteHelper = errors.New("origin is reached through a remote helper, which isn't run")

ErrRemoteHelper is returned for a clone whose origin is reached through a remote helper (a <helper>::<address> URL, after any insteadOf, or remote.origin.vcs): git looks for the helper as a program, then as an alias, which the clone's config can define, so an ls-remote there is refused before it runs.

View Source
var ErrRemoteTimeout = errors.New("origin didn't answer in time")

ErrRemoteTimeout is returned for an ls-remote that ran past RemoteTimeout, the only command here with a limit of its own.

View Source
var ErrWorkTree = errors.New("git doesn't take this folder as its clone's top folder")

ErrWorkTree is returned for a folder git doesn't take as its clone's top folder, as a subfolder of one, so no command that changes it runs there.

Functions

func Hardening

func Hardening() []string

Hardening returns the settings, ahead of its subcommand, that every git command the app runs to change a clone runs with: no hook from a hooks folder, the file system monitor off, and no submodule recursion. core.hooksPath points the hooks folder at an empty one. It doesn't reach the hooks a config names (hook.<name>.command and .event, from git 2.54): the clone's own hook.* settings refuse every command that could fire one (cloneconfig.go), which is what keeps them from running. Beside that, hook.<event>.enabled=false is set for every event git can fire (hookEvents): git 2.56 documents it as turning off every hook of the event, the user's own config hooks too, and a test shows it does there; a git whose config hooks predate that switch may read it as the switch of a hook named after the event, which turns off nothing, and a git older than config hooks ignores it. git runs hooks and the file system monitor with the clone as their working folder, so either could run a program the clone's own files hold, and a submodule's URL is the clone's to name. internal/worktrees runs each of its commands with them, and Repo scripts' pull too (RemoteSetup).

func IsCommitID

func IsCommitID(oid string) bool

IsCommitID reports a full commit ID, SHA-1 or SHA-256, that can name a commit. The null ID is refused: given as the old value to `update-ref -d` it turns the comparison off, and git reports it as the HEAD of a worktree with no commits. internal/worktrees holds its commit IDs to it too.

func Message

func Message(err error) string

Message is the part of a failure of one of gitread's commands, or of a command run with a Setup, worth showing the user: what git said, without the command and the exit status, or that origin didn't answer an ls-remote in time. A git failure's words are read from the *commandError in err's chain, not from err's text, so however a caller wraps it, its wrap never reaches the window. A clone whose own config sets settings a Setup refuses names them, and where to set them instead (CloneConfigError); a remote refused before anything ran says why, naming it (RefusedError, origin when none is named); and a command that failed after setting aside the clone's own ssh command, password program, or credential helpers says so, and where to set them instead.

func SetAsideNote

func SetAsideNote(remote string, settings []string) string

SetAsideNote says which of the clone's own settings, of SetAsideSSHCommand, SetAsideAskPass, and SetAsideHelpers, a command reaching the clone's remote called remote went without, which may be why it failed, and where to set them so that they are used: the user's global config, for this folder alone with an includeIf, which gitread counts as the user's own. It is "" for none.

func ValidBranch

func ValidBranch(name string) bool

ValidBranch reports a branch name the app may hand git as an argument: one that can't be read as an option, a range, a refspec's src:dst, or a pattern, and that git itself would take (validBranch).

func ValidRemoteName

func ValidRemoteName(name string) bool

ValidRemoteName reports a remote's name the app may pass to git, which can't be read as an option, a path, or a URL: remoteNamePattern, with no "..", and at most maxNameLen bytes. internal/worktrees holds the remotes it fetches from to it too.

Types

type Change

type Change struct {
	// Code is git's two-letter status, as in " M", "A ", "R ", or "??".
	Code string

	// Path is the file, relative to the worktree's top folder; for a rename or a copy,
	// its new name. An untracked folder ends in "/".
	Path string
}

Change is one changed or untracked file in a worktree.

type CloneConfigError

type CloneConfigError struct {
	// Keys are the settings, as git lists them (the section and the name lowercased), each
	// once, in the order git reads them, and Origins where each was first set, as git names
	// it (file:.git/config).
	Keys    []string
	Origins []string
}

CloneConfigError is a command that changes a clone refused before anything ran, as the clone's own git config sets settings cloneSettingAllowed doesn't allow.

func (*CloneConfigError) Error

func (e *CloneConfigError) Error() string

Error returns the refusal's text, with the settings and where each is set.

func (*CloneConfigError) Unwrap

func (e *CloneConfigError) Unwrap() error

Unwrap returns ErrCloneConfig.

type Config

type Config struct {
	// Env returns the environment each command starts from, read again for every
	// command: in the app, the login shell's (shellenv), so git, ssh, and the credential
	// helpers see what the user's terminal does. git is found on its PATH. It defaults to
	// os.Environ.
	Env func() []string

	// Runner returns what runs one command, given that command's whole environment. It
	// defaults to an execpath.Exec that runs with env and finds git on env's PATH, then
	// in the well-known tool folders (execpath.Search).
	Runner func(env []string) execpath.Runner
}

Config holds a Git's settings. Every field is optional.

type Entry

type Entry struct {
	// Code is git's two-letter status, "." standing for no change on that side, as in
	// ".M" (changed, not staged), "M." (staged), or "A."; "??" is an untracked file.
	Code string

	// Index names what the index holds for the file: its staged object, or, for an
	// unmerged file, its three stages' objects joined by ":"; "" for an untracked file. A
	// file staged again shows as a new Index even when Code stays the same.
	Index string

	// Path is the file, relative to the worktree's top folder; for a rename or a copy, its
	// new name, and From its old one.
	Path string
	From string
}

Entry is one changed, staged, unmerged, or untracked file in a worktree, as `git status --porcelain=v2` lists it.

type Git

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

Git runs allowlisted, read-only git commands. It is safe for concurrent use.

func New

func New(cfg Config) *Git

New returns a Git over cfg.

func (*Git) ChangedFiles added in v0.4.0

func (g *Git) ChangedFiles(ctx context.Context, dir, from, to string) ([]string, error)

ChangedFiles returns the files the commits from from to to changed, as paths from the worktree's top, each once, in git's order: the files a run's commits touched. It reads the two commits' trees alone, never a file's contents. It fails when the clone lacks either commit (see HasCommit).

func (*Git) Changes

func (g *Git) Changes(ctx context.Context, dir string) ([]Change, error)

Changes returns the worktree at dir's changed and untracked files, by `git status --porcelain`, which is the rule a release applies: any line means uncommitted changes.

func (*Git) CheckedOutElsewhere

func (g *Git) CheckedOutElsewhere(ctx context.Context, dir, branch string) ([]string, error)

CheckedOutElsewhere returns the folders of the clone's other worktrees, every one but the one at dir, that have branch checked out. dir must be a worktree's top folder.

func (*Git) CheckoutSetup

func (g *Git) CheckoutSetup(ctx context.Context, dir string) (Setup, error)

CheckoutSetup works out what a git command in the clone at dir that writes its files but reaches no remote runs with, as `git worktree add` does: RemoteSetup's, but that no remote is weighed and git may use no transport (Checkout), unless the clone is partial, whose promisor remotes are weighed as RemoteSetup weighs its remote.

func (*Git) CloneConfig

func (g *Git) CloneConfig(ctx context.Context, dir string) error

CloneConfig reads the clone at dir's whole config and refuses it as every Setup does before anything runs, reading only the clone: a setting of its own outside cloneSettingAllowed (a CloneConfigError naming them), and settings that change how a host is reached where Git LFS may run (cloneRoutes). Repo scripts' branch status asks it before offering a pull that would be refused.

func (*Git) CommitsBetween

func (g *Git) CommitsBetween(ctx context.Context, dir, from, to string) (int, error)

CommitsBetween returns how many commits the commit to has that the commit from doesn't, as `rev-list --count from..to` counts them: the commits a fast-forward from one to the other brought. It fails when the clone lacks either commit (see HasCommit).

func (*Git) CurrentBranch

func (g *Git) CurrentBranch(ctx context.Context, dir string) (string, error)

CurrentBranch returns the branch checked out in the worktree at dir, as in "main", or "" when HEAD is detached.

func (*Git) Entries

func (g *Git) Entries(ctx context.Context, dir string) ([]Entry, error)

Entries returns every changed, staged, unmerged, and untracked file in the worktree at dir, each untracked file listed on its own, by `git status --porcelain=v2 --untracked-files=all`, which names what the index holds for each. Taken before and after a tool runs, they tell which files it changed or staged.

func (*Git) GitFinder

func (g *Git) GitFinder() execpath.Finder

GitFinder returns what finds the git every Setup names, as every gitread command finds it: on the PATH of the environment Config.Env returns, the login shell's in the app, then in the well-known tool folders under its HOME. Core hands it to every other service that runs git on a clone, so one clone is never handled by two git builds.

func (*Git) HasCommit

func (g *Git) HasCommit(ctx context.Context, dir, oid string) (bool, error)

HasCommit reports whether the clone has the commit oid.

func (*Git) Head added in v0.4.0

func (g *Git) Head(ctx context.Context, dir string) (string, error)

Head returns the commit checked out in the worktree at dir, or "" when it has none yet, as a worktree made with no commits: what a run left there as it ended.

func (*Git) HookPaths

func (g *Git) HookPaths(ctx context.Context, dir string) (HookPaths, error)

HookPaths returns the worktree at dir's top folder, hooks folder, and common git folder, which together tell a hooks folder only this clone uses from one shared with others.

func (*Git) HooksDir

func (g *Git) HooksDir(ctx context.Context, dir string) (string, error)

HooksDir returns the folder git runs the worktree at dir's hooks from: core.hooksPath when set, else the hooks folder in the common git folder.

func (*Git) InProgress

func (g *Git) InProgress(ctx context.Context, dir string) (Operation, error)

InProgress returns what git is in the middle of in the worktree at dir: a rebase (or git am), a merge, a cherry-pick, or a revert, or OperationNone. It asks git where each one's file would be, which differs in a linked worktree, and looks for it.

func (*Git) IndexLocked

func (g *Git) IndexLocked(ctx context.Context, dir string) (bool, error)

IndexLocked reports whether the clone at dir's index is locked: whether git's index.lock, as a git that was writing the index, as a checkout does, leaves when it is cut off, is there. It asks git where the file would be, which differs in a linked worktree, and looks for it.

func (*Git) IsAncestor

func (g *Git) IsAncestor(ctx context.Context, dir, oid, of string) (bool, error)

IsAncestor reports whether the commit oid is of or one of its ancestors. It fails when the clone lacks either commit (see HasCommit).

func (*Git) LocalBranch

func (g *Git) LocalBranch(ctx context.Context, dir, branch string) (string, error)

LocalBranch returns the commit the clone's branch points at, or "" when it has no such branch.

func (*Git) LocalSetup

func (g *Git) LocalSetup(ctx context.Context, dir string) (Local, error)

LocalSetup works out what a git command in dir, a clone or one of its worktrees, that reaches no remote runs with (Local), reading the config git reads there: no command here reaches the network. A config git can't read, a folder that isn't absolute and clean, and no git refuse it; a clone whose own config holds a setting a Setup would refuse is told by Local.Refused, so a read that runs none of its programs can go on.

func (*Git) LocalTagCommit

func (g *Git) LocalTagCommit(ctx context.Context, dir, tag string) (string, error)

LocalTagCommit returns the commit the clone's version tag points at, peeled through an annotated tag, or "" when the clone has no such tag.

func (*Git) LocalVersionTags

func (g *Git) LocalVersionTags(ctx context.Context, dir string) ([]string, error)

LocalVersionTags returns the clone's version tags (v*), in git's order.

func (*Git) OriginHead

func (g *Git) OriginHead(ctx context.Context, dir string) (string, error)

OriginHead returns origin's default branch as the clone at dir last learned it, as in "main": the branch its refs/remotes/origin/HEAD points at, which git clone and git remote set-head write. It reads the clone's own refs and never asks origin. It is "" when the clone has no such ref, as one made with git init and git remote add, or when it doesn't name a branch of origin's.

func (*Git) ReadEnv

func (g *Git) ReadEnv() []string

ReadEnv returns the environment a read of a clone runs with, every gitread read's (environment) with replace refs ignored too: no transport (an empty GIT_ALLOW_PROTOCOL, which every git honors, so a partial clone's missing object is never fetched through a URL the clone names), no lazy fetch (GIT_NO_LAZY_FETCH, from git 2.44), no optional lock, no prompt, and no replace ref. The worktree service runs its own reads with it (git's --no-lazy-fetch, which only git 2.44 and later take, isn't passed: the app runs any git the user has).

func (*Git) RemoteBranch

func (g *Git) RemoteBranch(ctx context.Context, dir, branch string) (string, error)

RemoteBranch asks origin for one branch's commit (`ls-remote --heads origin refs/heads/<branch>`), and returns it, or "" when origin has no such branch, under every guard an ls-remote runs under: origin answers with that one branch, never every branch and tag it has. A branch ValidBranch refuses is refused (ErrGitCommandNotAllowed). It stops after RemoteTimeout.

func (*Git) RemoteRefs

func (g *Git) RemoteRefs(ctx context.Context, dir string) (RemoteRefs, error)

RemoteRefs asks origin for its branches and tags (`ls-remote --heads --tags origin`), which also says whether origin can be reached. It stops after RemoteTimeout.

func (*Git) RemoteSetup

func (g *Git) RemoteSetup(ctx context.Context, dir string) (Setup, error)

RemoteSetup works out what a git command in the clone at dir that reaches origin and writes the clone's files runs with (Setup), reading the clone's config, its folders, and origin's URL (`ls-remote --get-url`, which asks origin nothing): no command here reaches the network. It refuses, before anything runs, a clone whose own config holds a setting cloneSettingAllowed doesn't allow (a CloneConfigError naming them), a folder that isn't its clone's top folder (ErrWorkTree), what an ls-remote's guard refuses (an origin reached through a remote helper, a RefusedError naming it, for a partial clone its promisor remotes too), a clone whose own config reroutes a host where it would matter (ErrCloneRoutes), and a setting it can't pass safely (ErrGitCommandNotAllowed).

func (*Git) RemoteSetupFor

func (g *Git) RemoteSetupFor(ctx context.Context, dir, remote string) (Setup, error)

RemoteSetupFor is RemoteSetup for the clone's remote called remote, as worktree creation fetches from a fork's upstream: that remote's URL and remote helper are weighed in origin's place. A name that isn't one is refused (ErrGitCommandNotAllowed). Its Checkout serves the same clone's checkout.

func (*Git) RemoteTagCommit

func (g *Git) RemoteTagCommit(ctx context.Context, dir, tag string) (string, error)

RemoteTagCommit asks origin for the commit its version tag names, peeled, or "" when origin has no such tag. It stops after RemoteTimeout.

func (*Git) RemoteVersionTags

func (g *Git) RemoteVersionTags(ctx context.Context, dir string) ([]string, error)

RemoteVersionTags asks origin for its version tags (v*) and returns their names, sorted. It stops after RemoteTimeout.

func (*Git) Run

func (g *Git) Run(ctx context.Context, dir string, args ...string) (stdout, stderr []byte, err error)

Run runs `git -C dir -c core.fsmonitor=false -c submodule.recurse=false args...` and returns what git wrote, once args has passed the allowlist and dir is absolute and clean; otherwise it returns ErrGitCommandNotAllowed and runs nothing. A non-zero exit is an error that execpath.ExitCode reads. An ls-remote stops after RemoteTimeout, when the error wraps context.DeadlineExceeded. One that fails otherwise, after setting aside a setting the clone's own config makes, returns a *SetAsideError.

func (*Git) Signing

func (g *Git) Signing(ctx context.Context, dir string) (Signing, error)

Signing reads the clone's tag signing config.

func (*Git) TrackingBranch

func (g *Git) TrackingBranch(ctx context.Context, dir, branch string) (string, error)

TrackingBranch returns the commit origin's branch pointed at when the clone last learned it (refs/remotes/origin/<branch>), or "" when the clone has no such ref.

func (*Git) Unpushed

func (g *Git) Unpushed(ctx context.Context, dir, branch string) (int, error)

Unpushed returns how many commits the clone's branch has that origin's branch, as the clone last learned it, doesn't. It fails when either ref is missing (see LocalBranch and TrackingBranch).

func (*Git) Upstream

func (g *Git) Upstream(ctx context.Context, dir, branch string) (Upstream, error)

Upstream returns the upstream config of the clone's branch, which a release's `pull --rebase origin` needs. A key that isn't set is "".

func (*Git) WorktreeDiff added in v0.4.0

func (g *Git) WorktreeDiff(ctx context.Context, dir, from string) (WorktreeDiff, error)

WorktreeDiff returns the worktree at dir's changes since the commit from, committed or not, read-only: a diff from the commit to the worktree's files, run with no external diff, no textconv, and the clone's own filter drivers off, so it runs no program the clone names; and the files git doesn't track. It fails when the clone lacks the commit.

type HookPaths

type HookPaths struct {
	// Toplevel is the worktree's top folder.
	Toplevel string

	// Hooks is the folder git runs hooks from: core.hooksPath when set, else the hooks
	// folder in the common git folder.
	Hooks string

	// CommonDir is the git folder the clone's worktrees share, as in <clone>/.git.
	CommonDir string
}

HookPaths is where a worktree's hooks live, as git resolves them. A relative answer from git is made absolute against the folder asked about; an absolute one is kept as git gives it.

type Local

type Local struct {
	Setup

	// Refused, when set, is why a command there that could run one of the clone's own
	// programs, as a status's clean filter or a hook, must not run: the clone's own config
	// holds a setting cloneSettingAllowed doesn't allow (a CloneConfigError naming them).
	Refused error
}

Local is what a git command in a clone, or in one of its worktrees, that reaches no remote and writes no file of the clone's runs with (LocalSetup), as the worktrees' own status, removal, and branch deletion do: Setup's git and settings, the environment a read runs with (no transport, no lazy fetch, no optional lock, no replace ref), and every filter driver the clone's own config defines turned off, Git LFS's too, as a read does.

type Operation

type Operation string

Operation is what git is in the middle of in a worktree, if anything.

const (
	OperationNone          Operation = ""
	OperationRebasing      Operation = "rebasing"
	OperationMerging       Operation = "merging"
	OperationCherryPicking Operation = "cherry-picking"
	OperationReverting     Operation = "reverting"
)

The operations InProgress reports.

type RefusedError

type RefusedError struct {
	Remote string
	Err    error
}

RefusedError is a remote gitread's guards refused before anything ran: Remote is its name, and Err says why, ErrRemoteHelper or ErrCloneRoutes, with the setting or the URL that refused it.

func (*RefusedError) Error

func (e *RefusedError) Error() string

Error returns the refusal's text.

func (*RefusedError) Unwrap

func (e *RefusedError) Unwrap() error

Unwrap returns the refusal.

type RemoteRefs

type RemoteRefs struct {
	// Heads maps each branch, as in "main", to the commit it points at.
	Heads map[string]string

	// Tags maps each tag, as in "v1.4.2", to what it names.
	Tags map[string]RemoteTag
}

RemoteRefs is what origin has, as ls-remote lists it.

type RemoteTag

type RemoteTag struct {
	// Object is what the tag's ref points at: an annotated tag's own object, or a
	// lightweight tag's commit.
	Object string

	// Commit is the commit the tag names: the peeled one for an annotated tag.
	Commit string
}

RemoteTag is one of origin's tags.

type SetAsideError

type SetAsideError struct {
	// Err is the command's error, and Settings the settings set aside, of
	// SetAsideSSHCommand, SetAsideAskPass, and SetAsideHelpers.
	Err      error
	Settings []string

	// Remote is the remote the command reached, "" for origin.
	Remote string
}

SetAsideError is an ls-remote, or a fetch run with RemoteSetupFor's settings, that failed after gitread set aside settings, which may be why it failed: the clone picks its own ssh key with core.sshCommand, say, which gitread doesn't run. Its text is the command's own.

func (*SetAsideError) Error

func (e *SetAsideError) Error() string

Error returns the ls-remote's error's text.

func (*SetAsideError) Unwrap

func (e *SetAsideError) Unwrap() error

Unwrap returns the ls-remote's error.

type Setup

type Setup struct {
	// Git is git's absolute path, as GitFinder finds it: the git the command must run.
	Git string

	// Env is the command's whole environment, its settings in it, so its argv holds
	// nothing but git's own words:
	//
	//   - for one that reaches a remote, the ls-remote's (remoteGuard), with
	//     GIT_TERMINAL_PROMPT=0, the transports GIT_ALLOW_PROTOCOL allows, and the ssh
	//     command the user's own config or environment chose, else a batch-mode ssh; for one
	//     that reaches none (Checkout), the same but that it allows no transport.
	//     GIT_NO_LAZY_FETCH=1 is in it, but for a partial clone, whose promisor remotes the
	//     guard has weighed too;
	//   - GIT_DIR and GIT_WORK_TREE, the clone's git folder and the folder itself, which
	//     beat anything its config says;
	//   - Settings, through GIT_CONFIG_COUNT, after any the environment passes already.
	Env []string

	// Settings are the key=value settings Env passes, read only to say what they are:
	// Hardening's; fetchHardening's; the remote guard's, which set aside the clone's own
	// password program and credential helpers for the user's own, and save no cookie; and
	// every filter driver the clone's own config defines but Git LFS's turned off.
	Settings []string

	// SetAside names the clone's own settings set aside, of SetAsideSSHCommand,
	// SetAsideAskPass, and SetAsideHelpers, which may be why a command that reached a
	// remote failed: SetAsideNote says so.
	SetAside []string

	// Partial reports a partial clone, whose checkout may fetch a missing file's contents
	// from its promisor remote.
	Partial bool
}

Setup is what a git command that changes a clone runs with, Repo scripts' pull and worktree creation's fetches, ls-remote, and checkouts: the clone's own config weighed setting by setting first (cloneconfig.go), then every guard gitread's own ls-remote runs under, and those a status runs under, so a command that changes a clone is held tighter than the reads.

func (Setup) Checkout

func (s Setup) Checkout() Setup

Checkout returns s for a command that writes the clone's files and reaches no remote, as `git worktree add` does, from a Setup RemoteSetupFor worked out for the same clone: the same, but that git may use no transport, unless the clone is partial, whose checkout may fetch a missing file's contents from its promisor remotes, which the setup weighed.

type Signing

type Signing struct {
	// SignTags is tag.gpgSign: every annotated tag is signed.
	SignTags bool

	// SignAnnotated is tag.forceSignAnnotated: an annotated tag made without asking for
	// a signature is signed.
	SignAnnotated bool

	// Format is gpg.format, as in "openpgp", "x509", or "ssh", or "" when unset, which
	// git reads as openpgp.
	Format string

	// Key is user.signingkey as written, or "" when unset: a key ID, a key file (which
	// may start with ~), or a key itself.
	Key string
}

Signing is the clone's tag signing config, as git reads it there.

func (Signing) Signed

func (s Signing) Signed() bool

Signed reports whether git signs an annotated tag, such as the one a release makes.

type Upstream

type Upstream struct {
	// Remote is branch.<b>.remote, as in "origin", or "" when unset.
	Remote string

	// Ref is branch.<b>.merge, as in "refs/heads/main", or "" when unset.
	Ref string
}

Upstream is the branch a local branch is set to follow, from its config.

type WorktreeDiff added in v0.4.0

type WorktreeDiff struct {
	// Patch is git's unified diff from the commit to the worktree's files, at most MaxDiff
	// bytes, cut at a line's end; Cut reports a patch cut short.
	Patch string
	Cut   bool

	// Untracked are the files git doesn't track, which no patch shows, from the
	// worktree's top.
	Untracked []string
}

WorktreeDiff is a worktree's changes since a commit: what its commits since then changed, and what isn't committed yet, as one patch, and the files git doesn't track.

Jump to

Keyboard shortcuts

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