Skip to main content

Module git

Module git 

Source
Expand description

Git remotes (SPEC 9.6, 9.8): any git URL, through the system git CLI run in the store folder. The URL is passed to git unchanged; Surjection has no host-specific code paths besides the optional gh helper.

git [auth flags] push --progress <url> refs/heads/main:refs/heads/main 'refs/tags/*:refs/tags/*'
git [auth flags] fetch --progress <url> +refs/heads/main:refs/remotes/<name>/main '+refs/tags/*:refs/tags/*'

Auth (auth in state/remotes.toml):

  • system (default): no flags; whatever the user’s git does.
  • gh: -c credential.helper= -c 'credential.helper=!gh auth git-credential'.
  • token: -c credential.helper= -c 'credential.helper=!"<surjection>" git-credential --remote <name>'; the token comes from the OS keyring through super::credential.

No token is ever put in git’s environment or arguments. Git’s own prompts are off (GIT_TERMINAL_PROMPT=0; stdin is closed anyway); credential managers with their own windows still work. A git that prints nothing for IDLE_TIMEOUT is stopped. In a process that hides console windows (the app, crate::process::hide_console_windows), ssh runs in batch mode unless the user set their own ssh command (ssh_batch_mode): a passphrase or host-key prompt nobody could see fails at once instead of hanging until the idle timeout.

Structs§

GitCli
How to reach git and, for auth = token, this binary.
GitPush
What a push did.
Invocation
One process to run: program, arguments, the complete environment and the working directory. Kept as data so tests can check what a git receives.
RunOutput
What a finished (or stopped) process left.
SystemRunner
The real thing: stdin closed, stdout and stderr captured, stopped when silent for idle_timeout.

Enums§

GitAuth
How a git remote authenticates.

Constants§

IDLE_TIMEOUT
A git that prints nothing for this long is stopped (SPEC 9.6).
SSH_BATCH_COMMAND
The ssh command git runs from a process without console windows.

Traits§

Runner
Runs processes; tests record or script it.

Functions§

auth_args
The -c flags for the remote’s auth.
fetch
git fetch of main into refs/remotes/<name>/main and of every tag. None when the remote has no main yet (a new, empty repository).
git_not_found
tool_not_found for a missing git, as one sentence naming what needs it (#29): the app shows this message on its own, never after the generic “a required program is missing” text.
is_github_url
Whether url points at github.com (where auth = gh is offered).
locate
git on PATH. Relative PATH entries are skipped, so a project folder cannot shadow it.
pull
Fetches and merges the remote’s main (SPEC 9.9): tagged auto/pre-pull/<ts> when it brings anything; conflicts go to state/merge/MERGE_STATE.json and leave HEAD as it was.
push
git push of main and every tag. A non-fast-forward rejection pulls (merges) and retries once (SPEC 9.8); a pull with conflicts stops there with merge_conflict, and a pull that failed with its own error. Other rejections (a protected branch, a hook) are remote_rejected at once.
ssh_batch_mode
GIT_SSH_COMMAND=SSH_BATCH_COMMAND for a git started without a console window (hiding): ssh then fails at once (“Host key verification failed.”, “Permission denied (publickey).”) where it would ask for a passphrase or a new host key on a console nobody sees. Keys in ssh-agent still work. None when hiding is off, the program is not git, or the user chose an ssh command of their own (GIT_SSH_COMMAND or GIT_SSH in the environment, core.sshCommand in the arguments, or configured() saying git’s config sets it; an unknown answer counts as set). configured runs only when needed.
url_scheme_host
The scheme and host (with port) of url: https://host:port/path, ssh://user@host/path or scp-style user@host:path (scheme ssh). None for local paths and file://.