1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-remote-helpers(1)">
\r
6 <title>git-remote-helpers(1)</title>
\r
8 <primary>git-remote-helpers(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-remote-helpers - Helper programs to interact with remote repositories</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git remote-<transport></emphasis> <repository> [<URL>]</literallayout>
\r
21 <simplesect id="_description">
\r
22 <title>DESCRIPTION</title>
\r
23 <simpara>Remote helper programs are normally not used directly by end users,
\r
24 but they are invoked by git when it needs to interact with remote
\r
25 repositories git does not support natively. A given helper will
\r
26 implement a subset of the capabilities documented here. When git
\r
27 needs to interact with a repository using a remote helper, it spawns
\r
28 the helper as an independent process, sends commands to the helper's
\r
29 standard input, and expects results from the helper's standard
\r
30 output. Because a remote helper runs as an independent process from
\r
31 git, there is no need to re-link git to add a new helper, nor any
\r
32 need to link the helper with the implementation of git.</simpara>
\r
33 <simpara>Every helper must support the "capabilities" command, which git
\r
34 uses to determine what other commands the helper will accept. Those
\r
35 other commands can be used to discover and update remote refs,
\r
36 transport objects between the object database and the remote repository,
\r
37 and update the local object store.</simpara>
\r
38 <simpara>Git comes with a "curl" family of remote helpers, that handle various
\r
39 transport protocols, such as <emphasis>git-remote-http</emphasis>, <emphasis>git-remote-https</emphasis>,
\r
40 <emphasis>git-remote-ftp</emphasis> and <emphasis>git-remote-ftps</emphasis>. They implement the capabilities
\r
41 <emphasis>fetch</emphasis>, <emphasis>option</emphasis>, and <emphasis>push</emphasis>.</simpara>
\r
43 <simplesect id="_input_format">
\r
44 <title>INPUT FORMAT</title>
\r
45 <simpara>Git sends the remote helper a list of commands on standard input, one
\r
46 per line. The first command is always the <emphasis>capabilities</emphasis> command, in
\r
47 response to which the remote helper must print a list of the
\r
48 capabilities it supports (see below) followed by a blank line. The
\r
49 response to the capabilities command determines what commands Git uses
\r
50 in the remainder of the command stream.</simpara>
\r
51 <simpara>The command stream is terminated by a blank line. In some cases
\r
52 (indicated in the documentation of the relevant commands), this blank
\r
53 line is followed by a payload in some other protocol (e.g., the pack
\r
54 protocol), while in others it indicates the end of input.</simpara>
\r
55 <section id="_capabilities">
\r
56 <title>Capabilities</title>
\r
57 <simpara>Each remote helper is expected to support only a subset of commands.
\r
58 The operations a helper supports are declared to git in the response
\r
59 to the <emphasis>capabilities</emphasis> command (see COMMANDS, below).</simpara>
\r
63 <emphasis>option</emphasis>
\r
67 For specifying settings like <emphasis>verbosity</emphasis> (how much output to
\r
68 write to stderr) and <emphasis>depth</emphasis> (how much history is wanted in the
\r
69 case of a shallow clone) that affect how other commands are
\r
76 <emphasis>connect</emphasis>
\r
80 For fetching and pushing using git's native packfile protocol
\r
81 that requires a bidirectional, full-duplex connection.
\r
87 <emphasis>push</emphasis>
\r
91 For listing remote refs and pushing specified objects from the
\r
92 local object store to remote refs.
\r
98 <emphasis>fetch</emphasis>
\r
102 For listing remote refs and fetching the associated history to
\r
103 the local object store.
\r
109 <emphasis>import</emphasis>
\r
113 For listing remote refs and fetching the associated history as
\r
114 a fast-import stream.
\r
120 <emphasis>refspec</emphasis> <refspec>
\r
124 This modifies the <emphasis>import</emphasis> capability, allowing the produced
\r
125 fast-import stream to modify refs in a private namespace
\r
126 instead of writing to refs/heads or refs/remotes directly.
\r
127 It is recommended that all importers providing the <emphasis>import</emphasis>
\r
128 capability use this.
\r
130 <simpara>A helper advertising the capability
\r
131 <emphasis>refspec refs/heads/*:refs/svn/origin/branches/*</emphasis>
\r
132 is saying that, when it is asked to <emphasis>import refs/heads/topic</emphasis>, the
\r
133 stream it outputs will update the <emphasis>refs/svn/origin/branches/topic</emphasis>
\r
135 <simpara>This capability can be advertised multiple times. The first
\r
136 applicable refspec takes precedence. The left-hand of refspecs
\r
137 advertised with this capability must cover all refs reported by
\r
138 the list command. If no <emphasis>refspec</emphasis> capability is advertised,
\r
139 there is an implied <emphasis>refspec *:*</emphasis>.</simpara>
\r
144 <section id="_capabilities_for_pushing">
\r
145 <title>Capabilities for Pushing</title>
\r
149 <emphasis>connect</emphasis>
\r
153 Can attempt to connect to <emphasis>git receive-pack</emphasis> (for pushing),
\r
154 <emphasis>git upload-pack</emphasis>, etc for communication using the
\r
157 <simpara>Supported commands: <emphasis>connect</emphasis>.</simpara>
\r
162 <emphasis>push</emphasis>
\r
166 Can discover remote refs and push local commits and the
\r
167 history leading up to them to new or existing remote refs.
\r
169 <simpara>Supported commands: <emphasis>list for-push</emphasis>, <emphasis>push</emphasis>.</simpara>
\r
173 <simpara>If a helper advertises both <emphasis>connect</emphasis> and <emphasis>push</emphasis>, git will use
\r
174 <emphasis>connect</emphasis> if possible and fall back to <emphasis>push</emphasis> if the helper requests
\r
175 so when connecting (see the <emphasis>connect</emphasis> command under COMMANDS).</simpara>
\r
177 <section id="_capabilities_for_fetching">
\r
178 <title>Capabilities for Fetching</title>
\r
182 <emphasis>connect</emphasis>
\r
186 Can try to connect to <emphasis>git upload-pack</emphasis> (for fetching),
\r
187 <emphasis>git receive-pack</emphasis>, etc for communication using the
\r
190 <simpara>Supported commands: <emphasis>connect</emphasis>.</simpara>
\r
195 <emphasis>fetch</emphasis>
\r
199 Can discover remote refs and transfer objects reachable from
\r
200 them to the local object store.
\r
202 <simpara>Supported commands: <emphasis>list</emphasis>, <emphasis>fetch</emphasis>.</simpara>
\r
207 <emphasis>import</emphasis>
\r
211 Can discover remote refs and output objects reachable from
\r
212 them as a stream in fast-import format.
\r
214 <simpara>Supported commands: <emphasis>list</emphasis>, <emphasis>import</emphasis>.</simpara>
\r
218 <simpara>If a helper advertises <emphasis>connect</emphasis>, git will use it if possible and
\r
219 fall back to another capability if the helper requests so when
\r
220 connecting (see the <emphasis>connect</emphasis> command under COMMANDS).
\r
221 When choosing between <emphasis>fetch</emphasis> and <emphasis>import</emphasis>, git prefers <emphasis>fetch</emphasis>.
\r
222 Other frontends may have some other order of preference.</simpara>
\r
226 <emphasis>refspec</emphasis> <refspec>
\r
230 This modifies the <emphasis>import</emphasis> capability.
\r
232 <simpara>A helper advertising
\r
233 <emphasis>refspec refs/heads/*:refs/svn/origin/branches/*</emphasis>
\r
234 in its capabilities is saying that, when it handles
\r
235 <emphasis>import refs/heads/topic</emphasis>, the stream it outputs will update the
\r
236 <emphasis>refs/svn/origin/branches/topic</emphasis> ref.</simpara>
\r
237 <simpara>This capability can be advertised multiple times. The first
\r
238 applicable refspec takes precedence. The left-hand of refspecs
\r
239 advertised with this capability must cover all refs reported by
\r
240 the list command. If no <emphasis>refspec</emphasis> capability is advertised,
\r
241 there is an implied <emphasis>refspec *:*</emphasis>.</simpara>
\r
247 <simplesect id="_invocation">
\r
248 <title>INVOCATION</title>
\r
249 <simpara>Remote helper programs are invoked with one or (optionally) two
\r
250 arguments. The first argument specifies a remote repository as in git;
\r
251 it is either the name of a configured remote or a URL. The second
\r
252 argument specifies a URL; it is usually of the form
\r
253 <emphasis><transport>://<address></emphasis>, but any arbitrary string is possible.
\r
254 The <emphasis>GIT_DIR</emphasis> environment variable is set up for the remote helper
\r
255 and can be used to determine where to store additional data or from
\r
256 which directory to invoke auxiliary git commands.</simpara>
\r
257 <simpara>When git encounters a URL of the form <emphasis><transport>://<address></emphasis>, where
\r
258 <emphasis><transport></emphasis> is a protocol that it cannot handle natively, it
\r
259 automatically invokes <emphasis>git remote-<transport></emphasis> with the full URL as
\r
260 the second argument. If such a URL is encountered directly on the
\r
261 command line, the first argument is the same as the second, and if it
\r
262 is encountered in a configured remote, the first argument is the name
\r
263 of that remote.</simpara>
\r
264 <simpara>A URL of the form <emphasis><transport>::<address></emphasis> explicitly instructs git to
\r
265 invoke <emphasis>git remote-<transport></emphasis> with <emphasis><address></emphasis> as the second
\r
266 argument. If such a URL is encountered directly on the command line,
\r
267 the first argument is <emphasis><address></emphasis>, and if it is encountered in a
\r
268 configured remote, the first argument is the name of that remote.</simpara>
\r
269 <simpara>Additionally, when a configured remote has <emphasis>remote.<name>.vcs</emphasis> set to
\r
270 <emphasis><transport></emphasis>, git explicitly invokes <emphasis>git remote-<transport></emphasis> with
\r
271 <emphasis><name></emphasis> as the first argument. If set, the second argument is
\r
272 <emphasis>remote.<name>.url</emphasis>; otherwise, the second argument is omitted.</simpara>
\r
274 <simplesect id="_commands">
\r
275 <title>COMMANDS</title>
\r
276 <simpara>Commands are given by the caller on the helper's standard input, one per line.</simpara>
\r
280 <emphasis>capabilities</emphasis>
\r
284 Lists the capabilities of the helper, one per line, ending
\r
285 with a blank line. Each capability may be preceded with <emphasis>*</emphasis>,
\r
286 which marks them mandatory for git version using the remote
\r
287 helper to understand (unknown mandatory capability is fatal
\r
294 <emphasis>list</emphasis>
\r
298 Lists the refs, one per line, in the format "<value> <name>
\r
299 [<attr> …]". The value may be a hex sha1 hash, "@<dest>" for
\r
300 a symref, or "?" to indicate that the helper could not get the
\r
301 value of the ref. A space-separated list of attributes follows
\r
302 the name; unrecognized attributes are ignored. The list ends
\r
305 <simpara>If <emphasis>push</emphasis> is supported this may be called as <emphasis>list for-push</emphasis>
\r
306 to obtain the current refs prior to sending one or more <emphasis>push</emphasis>
\r
307 commands to the helper.</simpara>
\r
312 <emphasis>option</emphasis> <name> <value>
\r
316 Sets the transport helper option <name> to <value>. Outputs a
\r
317 single line containing one of <emphasis>ok</emphasis> (option successfully set),
\r
318 <emphasis>unsupported</emphasis> (option not recognized) or <emphasis>error <msg></emphasis>
\r
319 (option <name> is supported but <value> is not valid
\r
320 for it). Options should be set before other commands,
\r
321 and may influence the behavior of those commands.
\r
323 <simpara>Supported if the helper has the "option" capability.</simpara>
\r
328 <emphasis>fetch</emphasis> <sha1> <name>
\r
332 Fetches the given object, writing the necessary objects
\r
333 to the database. Fetch commands are sent in a batch, one
\r
334 per line, terminated with a blank line.
\r
335 Outputs a single blank line when all fetch commands in the
\r
336 same batch are complete. Only objects which were reported
\r
337 in the ref list with a sha1 may be fetched this way.
\r
339 <simpara>Optionally may output a <emphasis>lock <file></emphasis> line indicating a file under
\r
340 GIT_DIR/objects/pack which is keeping a pack until refs can be
\r
341 suitably updated.</simpara>
\r
342 <simpara>Supported if the helper has the "fetch" capability.</simpara>
\r
347 <emphasis>push</emphasis> +<src>:<dst>
\r
351 Pushes the given local <src> commit or branch to the
\r
352 remote branch described by <dst>. A batch sequence of
\r
353 one or more <emphasis>push</emphasis> commands is terminated with a blank line
\r
354 (if there is only one reference to push, a single <emphasis>push</emphasis> command
\r
355 is followed by a blank line). For example, the following would
\r
356 be two batches of <emphasis>push</emphasis>, the first asking the remote-helper
\r
357 to push the local ref <emphasis>master</emphasis> to the remote ref <emphasis>master</emphasis> and
\r
358 the local <emphasis>HEAD</emphasis> to the remote <emphasis>branch</emphasis>, and the second
\r
359 asking to push ref <emphasis>foo</emphasis> to ref <emphasis>bar</emphasis> (forced update requested
\r
360 by the <emphasis>+</emphasis>).
\r
362 <screen>push refs/heads/master:refs/heads/master
\r
363 push HEAD:refs/heads/branch
\r
365 push +refs/heads/foo:refs/heads/bar
\r
367 <simpara>Zero or more protocol options may be entered after the last <emphasis>push</emphasis>
\r
368 command, before the batch's terminating blank line.</simpara>
\r
369 <simpara>When the push is complete, outputs one or more <emphasis>ok <dst></emphasis> or
\r
370 <emphasis>error <dst> <why>?</emphasis> lines to indicate success or failure of
\r
371 each pushed ref. The status report output is terminated by
\r
372 a blank line. The option field <why> may be quoted in a C
\r
373 style string if it contains an LF.</simpara>
\r
374 <simpara>Supported if the helper has the "push" capability.</simpara>
\r
379 <emphasis>import</emphasis> <name>
\r
383 Produces a fast-import stream which imports the current value
\r
384 of the named ref. It may additionally import other refs as
\r
385 needed to construct the history efficiently. The script writes
\r
386 to a helper-specific private namespace. The value of the named
\r
387 ref should be written to a location in this namespace derived
\r
388 by applying the refspecs from the "refspec" capability to the
\r
391 <simpara>Especially useful for interoperability with a foreign versioning
\r
393 <simpara>Just like <emphasis>push</emphasis>, a batch sequence of one or more <emphasis>import</emphasis> is
\r
394 terminated with a blank line. For each batch of <emphasis>import</emphasis>, the remote
\r
395 helper should produce a fast-import stream terminated by a <emphasis>done</emphasis>
\r
397 <simpara>Supported if the helper has the "import" capability.</simpara>
\r
402 <emphasis>connect</emphasis> <service>
\r
406 Connects to given service. Standard input and standard output
\r
407 of helper are connected to specified service (git prefix is
\r
408 included in service name so e.g. fetching uses <emphasis>git-upload-pack</emphasis>
\r
409 as service) on remote side. Valid replies to this command are
\r
410 empty line (connection established), <emphasis>fallback</emphasis> (no smart
\r
411 transport support, fall back to dumb transports) and just
\r
412 exiting with error message printed (can't connect, don't
\r
413 bother trying to fall back). After line feed terminating the
\r
414 positive (empty) response, the output of service starts. After
\r
415 the connection ends, the remote helper exits.
\r
417 <simpara>Supported if the helper has the "connect" capability.</simpara>
\r
421 <simpara>If a fatal error occurs, the program writes the error message to
\r
422 stderr and exits. The caller should expect that a suitable error
\r
423 message has been printed if the child closes the connection without
\r
424 completing a valid response for the current command.</simpara>
\r
425 <simpara>Additional commands may be supported, as may be determined from
\r
426 capabilities reported by the helper.</simpara>
\r
428 <simplesect id="_ref_list_attributes">
\r
429 <title>REF LIST ATTRIBUTES</title>
\r
433 <emphasis>for-push</emphasis>
\r
437 The caller wants to use the ref list to prepare push
\r
438 commands. A helper might chose to acquire the ref list by
\r
439 opening a different type of connection to the destination.
\r
445 <emphasis>unchanged</emphasis>
\r
449 This ref is unchanged since the last import or fetch, although
\r
450 the helper cannot necessarily determine what value that produced.
\r
456 <simplesect id="_options">
\r
457 <title>OPTIONS</title>
\r
461 <emphasis>option verbosity</emphasis> <n>
\r
465 Changes the verbosity of messages displayed by the helper.
\r
466 A value of 0 for <n> means that processes operate
\r
467 quietly, and the helper produces only error output.
\r
468 1 is the default level of verbosity, and higher values
\r
469 of <n> correspond to the number of -v flags passed on the
\r
476 <emphasis>option progress</emphasis> {<emphasis>true</emphasis>|<emphasis>false</emphasis>}
\r
480 Enables (or disables) progress messages displayed by the
\r
481 transport helper during a command.
\r
487 <emphasis>option depth</emphasis> <depth>
\r
491 Deepens the history of a shallow repository.
\r
497 <emphasis>option followtags</emphasis> {<emphasis>true</emphasis>|<emphasis>false</emphasis>}
\r
501 If enabled the helper should automatically fetch annotated
\r
502 tag objects if the object the tag points at was transferred
\r
503 during the fetch command. If the tag is not fetched by
\r
504 the helper a second fetch command will usually be sent to
\r
505 ask for the tag specifically. Some helpers may be able to
\r
506 use this option to avoid a second network connection.
\r
511 <simpara><emphasis>option dry-run</emphasis> {<emphasis>true</emphasis>|<emphasis>false</emphasis>}:
\r
512 If true, pretend the operation completed successfully,
\r
513 but don't actually change any repository data. For most
\r
514 helpers this only applies to the <emphasis>push</emphasis>, if supported.</simpara>
\r
518 <emphasis>option servpath <c-style-quoted-path></emphasis>
\r
522 Sets service path (--upload-pack, --receive-pack etc.) for
\r
523 next connect. Remote helper may support this option, but
\r
524 must not rely on this option being set before
\r
525 connect request occurs.
\r
531 <simplesect id="_see_also">
\r
532 <title>SEE ALSO</title>
\r
533 <simpara><xref linkend="git-remote(1)" /></simpara>
\r
534 <simpara><xref linkend="git-remote-testgit(1)" /></simpara>
\r
536 <simplesect id="_git">
\r
538 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r