gitsafe

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 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 gitsafe builds the read-only git commands Zero runs on its own, as opposed to a git command the user or the model asked for: the status and diff calls behind the TUI's changed-files sweep, its pull request diffstat and the scratch-file warning, which run without anyone asking for git.

A REPOSITORY CAN MAKE THOSE COMMANDS RUN A PROGRAM. git status and git diff read the repository's own .git/config, and several keys there name programs git then runs: core.fsmonitor on every status, a clean filter or diff driver assigned through .gitattributes whenever a file's content has to be read, and hooks such as post-index-change when the index is rewritten. A repository unpacked from an archive or handed over as a directory carries that config, and Zero would run it on the first turn, although it refuses the same workspace's project hooks and plugins until the user trusts it.

The single-key cases are switched off on the command line. Filter and diff driver commands are named per driver, so they cannot be switched off without knowing the names; a repository whose own config defines any is skipped instead. Commands defined in the user's own global config, such as git-lfs, are the user's choice and are not affected.

Index

Constants

This section is empty.

Variables

View Source
var ErrRepositoryDefinesCommands = errors.New("the repository's own git config defines a filter or diff command, so Zero does not run git there on its own")

ErrRepositoryDefinesCommands is returned for a repository whose own config defines a filter or diff driver command. The caller goes without the git information rather than run it.

Functions

func Command

func Command(ctx context.Context, dir string, args ...string) (*exec.Cmd, error)

Command returns git with args, run in dir, with the programs a repository can configure turned off. It fails with ErrRepositoryDefinesCommands when the repository's own config defines a filter or diff driver command, and with git's own error when dir is not inside a repository.

Callers that inspect a work tree that may contain submodules should also pass --ignore-submodules=dirty: a submodule has its own config, which this does not read, and git only runs commands there when it looks inside the submodule.

Types

type Checked

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

Checked is a directory whose repository config Check has read, for running several commands there at the cost of one config read. Reading the config takes a git process of its own, and a caller that runs git more than once per call, like Scan on every turn, would otherwise pay for it each time.

func Check

func Check(ctx context.Context, dir string) (*Checked, error)

Check reads the repository config for dir and fails the way Command does: with ErrRepositoryDefinesCommands, or with git's own error when dir is not inside a repository.

func (*Checked) Command

func (checked *Checked) Command(ctx context.Context, args ...string) *exec.Cmd

Command returns git with args, run in the checked directory, with the programs a repository can configure turned off.

Jump to

Keyboard shortcuts

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