@@ -24,22 +24,141 @@ output. Because a remote helper runs as an independent process from
24
24
git, there is no need to re-link git to add a new helper, nor any
25
25
need to link the helper with the implementation of git.
26
26
27
- Every helper must support the "capabilities" command, which git will
28
- use to determine what other commands the helper will accept. Other
29
- commands generally concern facilities like discovering and updating
30
- remote refs, transporting objects between the object database and
31
- the remote repository, and updating the local object store.
32
-
33
- Helpers supporting the 'fetch' capability can discover refs from the
34
- remote repository and transfer objects reachable from those refs to
35
- the local object store. Helpers supporting the 'push' capability can
36
- transfer local objects to the remote repository and update remote refs.
27
+ Every helper must support the "capabilities" command, which git
28
+ uses to determine what other commands the helper will accept. Those
29
+ other commands can be used to discover and update remote refs,
30
+ transport objects between the object database and the remote repository,
31
+ and update the local object store.
37
32
38
33
Git comes with a "curl" family of remote helpers, that handle various
39
34
transport protocols, such as 'git-remote-http', 'git-remote-https',
40
35
'git-remote-ftp' and 'git-remote-ftps'. They implement the capabilities
41
36
'fetch', 'option', and 'push'.
42
37
38
+ INPUT FORMAT
39
+ ------------
40
+
41
+ Git sends the remote helper a list of commands on standard input, one
42
+ per line. The first command is always the 'capabilities' command, in
43
+ response to which the remote helper must print a list of the
44
+ capabilities it supports (see below) followed by a blank line. The
45
+ response to the capabilities command determines what commands Git uses
46
+ in the remainder of the command stream.
47
+
48
+ The command stream is terminated by a blank line. In some cases
49
+ (indicated in the documentation of the relevant commands), this blank
50
+ line is followed by a payload in some other protocol (e.g., the pack
51
+ protocol), while in others it indicates the end of input.
52
+
53
+ Capabilities
54
+ ~~~~~~~~~~~~
55
+
56
+ Each remote helper is expected to support only a subset of commands.
57
+ The operations a helper supports are declared to git in the response
58
+ to the `capabilities` command (see COMMANDS, below).
59
+
60
+ 'option'::
61
+ For specifying settings like `verbosity` (how much output to
62
+ write to stderr) and `depth` (how much history is wanted in the
63
+ case of a shallow clone) that affect how other commands are
64
+ carried out.
65
+
66
+ 'connect'::
67
+ For fetching and pushing using git's native packfile protocol
68
+ that requires a bidirectional, full-duplex connection.
69
+
70
+ 'push'::
71
+ For listing remote refs and pushing specified objects from the
72
+ local object store to remote refs.
73
+
74
+ 'fetch'::
75
+ For listing remote refs and fetching the associated history to
76
+ the local object store.
77
+
78
+ 'import'::
79
+ For listing remote refs and fetching the associated history as
80
+ a fast-import stream.
81
+
82
+ 'refspec' <refspec>::
83
+ This modifies the 'import' capability, allowing the produced
84
+ fast-import stream to modify refs in a private namespace
85
+ instead of writing to refs/heads or refs/remotes directly.
86
+ It is recommended that all importers providing the 'import'
87
+ capability use this.
88
+ +
89
+ A helper advertising the capability
90
+ `refspec refs/heads/{asterisk}:refs/svn/origin/branches/{asterisk}`
91
+ is saying that, when it is asked to `import refs/heads/topic`, the
92
+ stream it outputs will update the `refs/svn/origin/branches/topic`
93
+ ref.
94
+ +
95
+ This capability can be advertised multiple times. The first
96
+ applicable refspec takes precedence. The left-hand of refspecs
97
+ advertised with this capability must cover all refs reported by
98
+ the list command. If no 'refspec' capability is advertised,
99
+ there is an implied `refspec {asterisk}:{asterisk}`.
100
+
101
+ Capabilities for Pushing
102
+ ~~~~~~~~~~~~~~~~~~~~~~~~
103
+ 'connect'::
104
+ Can attempt to connect to 'git receive-pack' (for pushing),
105
+ 'git upload-pack', etc for communication using the
106
+ packfile protocol.
107
+ +
108
+ Supported commands: 'connect'.
109
+
110
+ 'push'::
111
+ Can discover remote refs and push local commits and the
112
+ history leading up to them to new or existing remote refs.
113
+ +
114
+ Supported commands: 'list for-push', 'push'.
115
+
116
+ If a helper advertises both 'connect' and 'push', git will use
117
+ 'connect' if possible and fall back to 'push' if the helper requests
118
+ so when connecting (see the 'connect' command under COMMANDS).
119
+
120
+ Capabilities for Fetching
121
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
122
+ 'connect'::
123
+ Can try to connect to 'git upload-pack' (for fetching),
124
+ 'git receive-pack', etc for communication using the
125
+ packfile protocol.
126
+ +
127
+ Supported commands: 'connect'.
128
+
129
+ 'fetch'::
130
+ Can discover remote refs and transfer objects reachable from
131
+ them to the local object store.
132
+ +
133
+ Supported commands: 'list', 'fetch'.
134
+
135
+ 'import'::
136
+ Can discover remote refs and output objects reachable from
137
+ them as a stream in fast-import format.
138
+ +
139
+ Supported commands: 'list', 'import'.
140
+
141
+ If a helper advertises 'connect', git will use it if possible and
142
+ fall back to another capability if the helper requests so when
143
+ connecting (see the 'connect' command under COMMANDS).
144
+ When choosing between 'fetch' and 'import', git prefers 'fetch'.
145
+ Other frontends may have some other order of preference.
146
+
147
+ 'refspec' <refspec>::
148
+ This modifies the 'import' capability.
149
+ +
150
+ A helper advertising
151
+ `refspec refs/heads/{asterisk}:refs/svn/origin/branches/{asterisk}`
152
+ in its capabilities is saying that, when it handles
153
+ `import refs/heads/topic`, the stream it outputs will update the
154
+ `refs/svn/origin/branches/topic` ref.
155
+ +
156
+ This capability can be advertised multiple times. The first
157
+ applicable refspec takes precedence. The left-hand of refspecs
158
+ advertised with this capability must cover all refs reported by
159
+ the list command. If no 'refspec' capability is advertised,
160
+ there is an implied `refspec {asterisk}:{asterisk}`.
161
+
43
162
INVOCATION
44
163
----------
45
164
@@ -122,7 +241,22 @@ Supported if the helper has the "fetch" capability.
122
241
'push' +<src>:<dst>::
123
242
Pushes the given local <src> commit or branch to the
124
243
remote branch described by <dst>. A batch sequence of
125
- one or more push commands is terminated with a blank line.
244
+ one or more 'push' commands is terminated with a blank line
245
+ (if there is only one reference to push, a single 'push' command
246
+ is followed by a blank line). For example, the following would
247
+ be two batches of 'push', the first asking the remote-helper
248
+ to push the local ref 'master' to the remote ref 'master' and
249
+ the local 'HEAD' to the remote 'branch', and the second
250
+ asking to push ref 'foo' to ref 'bar' (forced update requested
251
+ by the '+').
252
+ +
253
+ ------------
254
+ push refs/heads/master:refs/heads/master
255
+ push HEAD:refs/heads/branch
256
+ \n
257
+ push +refs/heads/foo:refs/heads/bar
258
+ \n
259
+ ------------
126
260
+
127
261
Zero or more protocol options may be entered after the last 'push'
128
262
command, before the batch's terminating blank line.
@@ -147,6 +281,11 @@ Supported if the helper has the "push" capability.
147
281
Especially useful for interoperability with a foreign versioning
148
282
system.
149
283
+
284
+ Just like 'push', a batch sequence of one or more 'import' is
285
+ terminated with a blank line. For each batch of 'import', the remote
286
+ helper should produce a fast-import stream terminated by a 'done'
287
+ command.
288
+ +
150
289
Supported if the helper has the "import" capability.
151
290
152
291
'connect' <service>::
@@ -171,26 +310,6 @@ completing a valid response for the current command.
171
310
Additional commands may be supported, as may be determined from
172
311
capabilities reported by the helper.
173
312
174
- CAPABILITIES
175
- ------------
176
-
177
- 'fetch'::
178
- 'option'::
179
- 'push'::
180
- 'import'::
181
- 'connect'::
182
- This helper supports the corresponding command with the same name.
183
-
184
- 'refspec' 'spec'::
185
- When using the import command, expect the source ref to have
186
- been written to the destination ref. The earliest applicable
187
- refspec takes precedence. For example
188
- "refs/heads/{asterisk}:refs/svn/origin/branches/{asterisk}" means
189
- that, after an "import refs/heads/name", the script has written to
190
- refs/svn/origin/branches/name. If this capability is used at
191
- all, it must cover all refs reported by the list command; if
192
- it is not used, it is effectively "{asterisk}:{asterisk}"
193
-
194
313
REF LIST ATTRIBUTES
195
314
-------------------
196
315
@@ -243,6 +362,8 @@ SEE ALSO
243
362
--------
244
363
linkgit:git-remote[1]
245
364
365
+ linkgit:git-remote-testgit[1]
366
+
246
367
GIT
247
368
---
248
369
Part of the linkgit:git[1] suite
0 commit comments