Documentation / git-remote-helpers.txton commit fast-import: introduce 'done' command (be56862)
   1git-remote-helpers(1)
   2=====================
   3
   4NAME
   5----
   6git-remote-helpers - Helper programs to interact with remote repositories
   7
   8SYNOPSIS
   9--------
  10'git remote-<transport>' <repository> [<URL>]
  11
  12DESCRIPTION
  13-----------
  14
  15Remote helper programs are normally not used directly by end users,
  16but they are invoked by git when it needs to interact with remote
  17repositories git does not support natively.  A given helper will
  18implement a subset of the capabilities documented here. When git
  19needs to interact with a repository using a remote helper, it spawns
  20the helper as an independent process, sends commands to the helper's
  21standard input, and expects results from the helper's standard
  22output. Because a remote helper runs as an independent process from
  23git, there is no need to re-link git to add a new helper, nor any
  24need to link the helper with the implementation of git.
  25
  26Every helper must support the "capabilities" command, which git will
  27use to determine what other commands the helper will accept.  Other
  28commands generally concern facilities like discovering and updating
  29remote refs, transporting objects between the object database and
  30the remote repository, and updating the local object store.
  31
  32Helpers supporting the 'fetch' capability can discover refs from the
  33remote repository and transfer objects reachable from those refs to
  34the local object store. Helpers supporting the 'push' capability can
  35transfer local objects to the remote repository and update remote refs.
  36
  37Git comes with a "curl" family of remote helpers, that handle various
  38transport protocols, such as 'git-remote-http', 'git-remote-https',
  39'git-remote-ftp' and 'git-remote-ftps'. They implement the capabilities
  40'fetch', 'option', and 'push'.
  41
  42INVOCATION
  43----------
  44
  45Remote helper programs are invoked with one or (optionally) two
  46arguments. The first argument specifies a remote repository as in git;
  47it is either the name of a configured remote or a URL. The second
  48argument specifies a URL; it is usually of the form
  49'<transport>://<address>', but any arbitrary string is possible.
  50The 'GIT_DIR' environment variable is set up for the remote helper
  51and can be used to determine where to store additional data or from
  52which directory to invoke auxiliary git commands.
  53
  54When git encounters a URL of the form '<transport>://<address>', where
  55'<transport>' is a protocol that it cannot handle natively, it
  56automatically invokes 'git remote-<transport>' with the full URL as
  57the second argument. If such a URL is encountered directly on the
  58command line, the first argument is the same as the second, and if it
  59is encountered in a configured remote, the first argument is the name
  60of that remote.
  61
  62A URL of the form '<transport>::<address>' explicitly instructs git to
  63invoke 'git remote-<transport>' with '<address>' as the second
  64argument. If such a URL is encountered directly on the command line,
  65the first argument is '<address>', and if it is encountered in a
  66configured remote, the first argument is the name of that remote.
  67
  68Additionally, when a configured remote has 'remote.<name>.vcs' set to
  69'<transport>', git explicitly invokes 'git remote-<transport>' with
  70'<name>' as the first argument. If set, the second argument is
  71'remote.<name>.url'; otherwise, the second argument is omitted.
  72
  73COMMANDS
  74--------
  75
  76Commands are given by the caller on the helper's standard input, one per line.
  77
  78'capabilities'::
  79        Lists the capabilities of the helper, one per line, ending
  80        with a blank line. Each capability may be preceded with '*',
  81        which marks them mandatory for git version using the remote
  82        helper to understand (unknown mandatory capability is fatal
  83        error).
  84
  85'list'::
  86        Lists the refs, one per line, in the format "<value> <name>
  87        [<attr> ...]". The value may be a hex sha1 hash, "@<dest>" for
  88        a symref, or "?" to indicate that the helper could not get the
  89        value of the ref. A space-separated list of attributes follows
  90        the name; unrecognized attributes are ignored. The list ends
  91        with a blank line.
  92+
  93If 'push' is supported this may be called as 'list for-push'
  94to obtain the current refs prior to sending one or more 'push'
  95commands to the helper.
  96
  97'option' <name> <value>::
  98        Sets the transport helper option <name> to <value>.  Outputs a
  99        single line containing one of 'ok' (option successfully set),
 100        'unsupported' (option not recognized) or 'error <msg>'
 101        (option <name> is supported but <value> is not valid
 102        for it).  Options should be set before other commands,
 103        and may influence the behavior of those commands.
 104+
 105Supported if the helper has the "option" capability.
 106
 107'fetch' <sha1> <name>::
 108        Fetches the given object, writing the necessary objects
 109        to the database.  Fetch commands are sent in a batch, one
 110        per line, terminated with a blank line.
 111        Outputs a single blank line when all fetch commands in the
 112        same batch are complete. Only objects which were reported
 113        in the ref list with a sha1 may be fetched this way.
 114+
 115Optionally may output a 'lock <file>' line indicating a file under
 116GIT_DIR/objects/pack which is keeping a pack until refs can be
 117suitably updated.
 118+
 119Supported if the helper has the "fetch" capability.
 120
 121'push' +<src>:<dst>::
 122        Pushes the given local <src> commit or branch to the
 123        remote branch described by <dst>.  A batch sequence of
 124        one or more push commands is terminated with a blank line.
 125+
 126Zero or more protocol options may be entered after the last 'push'
 127command, before the batch's terminating blank line.
 128+
 129When the push is complete, outputs one or more 'ok <dst>' or
 130'error <dst> <why>?' lines to indicate success or failure of
 131each pushed ref.  The status report output is terminated by
 132a blank line.  The option field <why> may be quoted in a C
 133style string if it contains an LF.
 134+
 135Supported if the helper has the "push" capability.
 136
 137'import' <name>::
 138        Produces a fast-import stream which imports the current value
 139        of the named ref. It may additionally import other refs as
 140        needed to construct the history efficiently. The script writes
 141        to a helper-specific private namespace. The value of the named
 142        ref should be written to a location in this namespace derived
 143        by applying the refspecs from the "refspec" capability to the
 144        name of the ref.
 145+
 146Especially useful for interoperability with a foreign versioning
 147system.
 148+
 149Supported if the helper has the "import" capability.
 150
 151'connect' <service>::
 152        Connects to given service. Standard input and standard output
 153        of helper are connected to specified service (git prefix is
 154        included in service name so e.g. fetching uses 'git-upload-pack'
 155        as service) on remote side. Valid replies to this command are
 156        empty line (connection established), 'fallback' (no smart
 157        transport support, fall back to dumb transports) and just
 158        exiting with error message printed (can't connect, don't
 159        bother trying to fall back). After line feed terminating the
 160        positive (empty) response, the output of service starts. After
 161        the connection ends, the remote helper exits.
 162+
 163Supported if the helper has the "connect" capability.
 164
 165If a fatal error occurs, the program writes the error message to
 166stderr and exits. The caller should expect that a suitable error
 167message has been printed if the child closes the connection without
 168completing a valid response for the current command.
 169
 170Additional commands may be supported, as may be determined from
 171capabilities reported by the helper.
 172
 173CAPABILITIES
 174------------
 175
 176'fetch'::
 177'option'::
 178'push'::
 179'import'::
 180'connect'::
 181        This helper supports the corresponding command with the same name.
 182
 183'refspec' 'spec'::
 184        When using the import command, expect the source ref to have
 185        been written to the destination ref. The earliest applicable
 186        refspec takes precedence. For example
 187        "refs/heads/{asterisk}:refs/svn/origin/branches/{asterisk}" means
 188        that, after an "import refs/heads/name", the script has written to
 189        refs/svn/origin/branches/name. If this capability is used at
 190        all, it must cover all refs reported by the list command; if
 191        it is not used, it is effectively "{asterisk}:{asterisk}"
 192
 193REF LIST ATTRIBUTES
 194-------------------
 195
 196'for-push'::
 197        The caller wants to use the ref list to prepare push
 198        commands.  A helper might chose to acquire the ref list by
 199        opening a different type of connection to the destination.
 200
 201'unchanged'::
 202        This ref is unchanged since the last import or fetch, although
 203        the helper cannot necessarily determine what value that produced.
 204
 205OPTIONS
 206-------
 207'option verbosity' <n>::
 208        Changes the verbosity of messages displayed by the helper.
 209        A value of 0 for <n> means that processes operate
 210        quietly, and the helper produces only error output.
 211        1 is the default level of verbosity, and higher values
 212        of <n> correspond to the number of -v flags passed on the
 213        command line.
 214
 215'option progress' \{'true'|'false'\}::
 216        Enables (or disables) progress messages displayed by the
 217        transport helper during a command.
 218
 219'option depth' <depth>::
 220        Deepens the history of a shallow repository.
 221
 222'option followtags' \{'true'|'false'\}::
 223        If enabled the helper should automatically fetch annotated
 224        tag objects if the object the tag points at was transferred
 225        during the fetch command.  If the tag is not fetched by
 226        the helper a second fetch command will usually be sent to
 227        ask for the tag specifically.  Some helpers may be able to
 228        use this option to avoid a second network connection.
 229
 230'option dry-run' \{'true'|'false'\}:
 231        If true, pretend the operation completed successfully,
 232        but don't actually change any repository data.  For most
 233        helpers this only applies to the 'push', if supported.
 234
 235'option servpath <c-style-quoted-path>'::
 236        Sets service path (--upload-pack, --receive-pack etc.) for
 237        next connect. Remote helper may support this option, but
 238        must not rely on this option being set before
 239        connect request occurs.
 240
 241SEE ALSO
 242--------
 243linkgit:git-remote[1]
 244
 245GIT
 246---
 247Part of the linkgit:git[1] suite