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 ¶
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 ¶
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.