SwarmOps

Page kind: Reference

swarmops auth git-credential#

Describes v0.13.0Last changed View as Markdown

Answer git's credential-helper protocol from your login file.

For a plain git to use a login: git -c credential.helper='!so auth git-credential' push. git adds the operation as the last word and writes its request on stdin, key=value lines up to a blank line; at most 64 KiB are read. get prints two lines on stdout, username=x-access-token and password= with the login's token, when the request's protocol is https (or http to a loopback address) and its host is exactly a login's, port included, of a provider this build knows. For anything else it prints nothing and exits 0, and git asks its next helper. store, erase and any other word print nothing and change nothing: a remote that refuses the token does not remove the login.

It prints no envelope: stdout belongs to git. A login file that is refused, a request that cannot be read and a command line it refuses have their envelope on stderr, with its exit code, and nothing on stdout. It uses no store and needs no identity. No other command prints a token.

Metadata
Group
auth
Since
0.12.0
Mutates
no
Identity required
no
MCP tool
none
Envelope op
auth_git_credential
Exit codes
0
Errors
none

Syntax#

Syntax
swarmops auth git-credential [OPTIONS] <OPERATION>

Required arguments#

Syntax: <OPERATION>.

The operation git names: get, store or erase.

Optional arguments#

The command also takes the global options.

Examples#

No recorded example yet.

Details#

auth git-credential is the command git runs, not one a person types: it answers git's credential-helper protocol from your login file, so that a plain git can use the token auth login kept. SwarmOps's own commands do not need it: clone, fetch, push and sync send the login's token themselves (Where the login is used).

It opens no store: --repo and --as are read and not used. It has no MCP tool: it speaks git's protocol on stdin and stdout, and prints a token.

Telling git to use it#

For one command:

Shell
git -c credential.helper='!so auth git-credential' push

For every repository of yours:

Shell
git config --global credential.helper '!so auth git-credential'

git runs the helper when a remote asks for a credential, with the operation as its last word, and asks its other helpers when this one has no answer. Name the binary by an absolute path where so is not on the PATH git runs with.

What it answers#

git writes its request on stdin, key=value lines up to a blank line. At most 64 KiB are read.

OperationWhat happens
getFor a request a login is for, two lines on stdout: username=x-access-token and password= with the login's token. For any other request, nothing.
storeNothing: the helper keeps only what auth login kept.
eraseNothing: a remote that refuses the token does not remove the login.
any other wordNothing.

A request is one a login is for when both hold:

  1. The protocol is https, or http with a host that is a literal loopback address.
  2. The host is equal to a login's, port included: a login for github.com answers a request for github.com and for github.com:443, and none for gist.github.com or github.com:8443. Only a login of a provider this build knows is given.

The request's other keys (path, username, the ones newer gits add) are passed over. The answer never says quit, so git stays free to ask its next helper. In every case without an answer the exit code is 0 and both streams are empty.

Text
protocol=https
host=github.com

is answered

Text
username=x-access-token
password=<the token>

Streams and failures#

stdout belongs to git, so the command prints no envelope there. This is the only command that prints a token, and it prints it on stdout alone.

A failure leaves stdout empty and puts its envelope on stderr, with the envelope's exit code; git then goes on as if the helper had no answer, and shows what the helper wrote:

FailureEnvelope
A login file that is refused (auth login)E_INVALID_ARG with details.auth_file and the file's details.reason
A request longer than 64 KiB, or one that cannot be readE_INVALID_ARG, details.reason credential_request
No operation, or a flag it does not knowE_INVALID_ARG, the usage error

The login file is opened only for a get whose protocol and host could be a login's: store, erase and a request for ssh never fail on the file. No envelope and no message holds the token or what stdin held.

Return information#

swarmops auth git-credential prints no envelope on stdout, which git reads as a credential helper's: for get with a login for the request's host, a username= line and a password= line, and otherwise nothing. A login file that is refused, a request it cannot read and a command line it refuses have their envelope on stderr.

Envelope op: auth_git_credential.

Exit codes:

  • 0: Success.

Errors#

No golden step shows this command failing yet.

Any command that opens a store may also fail with a store error, such as E_NOT_A_REPO, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).

See also#

On this page