View Javadoc
1   /*
2    * Copyright (C) 2008, 2013 Google Inc.
3    * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
4    * Copyright (C) 2008, 2022 Shawn O. Pearce <spearce@spearce.org> and others
5    *
6    * This program and the accompanying materials are made available under the
7    * terms of the Eclipse Distribution License v. 1.0 which is available at
8    * https://www.eclipse.org/org/documents/edl-v10.php.
9    *
10   * SPDX-License-Identifier: BSD-3-Clause
11   */
12  
13  package org.eclipse.jgit.transport;
14  
15  /**
16   * Wire constants for the native Git protocol.
17   *
18   * @since 3.2
19   */
20  public final class GitProtocolConstants {
21  	/**
22  	 * Include tags if we are also including the referenced objects.
23  	 *
24  	 * @since 3.2
25  	 */
26  	public static final String OPTION_INCLUDE_TAG = "include-tag"; //$NON-NLS-1$
27  
28  	/**
29  	 * Multi-ACK support for improved negotiation.
30  	 *
31  	 * @since 3.2
32  	 */
33  	public static final String OPTION_MULTI_ACK = "multi_ack"; //$NON-NLS-1$
34  
35  	/**
36  	 * Multi-ACK detailed support for improved negotiation.
37  	 *
38  	 * @since 3.2
39  	 */
40  	public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed"; //$NON-NLS-1$
41  
42  	/**
43  	 * The client supports packs with deltas but not their bases.
44  	 *
45  	 * @since 3.2
46  	 */
47  	public static final String OPTION_THIN_PACK = "thin-pack"; //$NON-NLS-1$
48  
49  	/**
50  	 * The client supports using the side-band for progress messages.
51  	 *
52  	 * @since 3.2
53  	 */
54  	public static final String OPTION_SIDE_BAND = "side-band"; //$NON-NLS-1$
55  
56  	/**
57  	 * The client supports using the 64K side-band for progress messages.
58  	 *
59  	 * @since 3.2
60  	 */
61  	public static final String OPTION_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$
62  
63  	/**
64  	 * The client supports packs with OFS deltas.
65  	 *
66  	 * @since 3.2
67  	 */
68  	public static final String OPTION_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$
69  
70  	/**
71  	 * The client supports shallow fetches.
72  	 *
73  	 * @since 3.2
74  	 */
75  	public static final String OPTION_SHALLOW = "shallow"; //$NON-NLS-1$
76  
77  	/**
78  	 * The client wants the "deepen" command to be interpreted as relative to
79  	 * the client's shallow commits.
80  	 *
81  	 * @since 5.0
82  	 */
83  	public static final String OPTION_DEEPEN_RELATIVE = "deepen-relative"; //$NON-NLS-1$
84  
85  	/**
86  	 * The client does not want progress messages and will ignore them.
87  	 *
88  	 * @since 3.2
89  	 */
90  	public static final String OPTION_NO_PROGRESS = "no-progress"; //$NON-NLS-1$
91  
92  	/**
93  	 * The client supports receiving a pack before it has sent "done".
94  	 *
95  	 * @since 3.2
96  	 */
97  	public static final String OPTION_NO_DONE = "no-done"; //$NON-NLS-1$
98  
99  	/**
100 	 * The client supports fetching objects at the tip of any ref, even if not
101 	 * advertised.
102 	 *
103 	 * @since 3.2
104 	 */
105 	public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$
106 
107 	/**
108 	 * The client supports fetching objects that are reachable from a tip of a
109 	 * ref that is allowed to fetch.
110 	 *
111 	 * @since 4.1
112 	 */
113 	public static final String OPTION_ALLOW_REACHABLE_SHA1_IN_WANT = "allow-reachable-sha1-in-want"; //$NON-NLS-1$
114 
115 	/**
116 	 * Symbolic reference support for better negotiation.
117 	 *
118 	 * @since 3.6
119 	 */
120 	public static final String OPTION_SYMREF = "symref"; //$NON-NLS-1$
121 
122 	/**
123 	 * The client will send a push certificate.
124 	 *
125 	 * @since 4.0
126 	 */
127 	public static final String OPTION_PUSH_CERT = "push-cert"; //$NON-NLS-1$
128 
129 	/**
130 	 * The client specified a filter expression.
131 	 *
132 	 * @since 5.0
133 	 */
134 	public static final String OPTION_FILTER = "filter"; //$NON-NLS-1$
135 
136 	/**
137 	 * The client specified a want-ref expression.
138 	 *
139 	 * @since 5.1
140 	 */
141 	public static final String OPTION_WANT_REF = "want-ref"; //$NON-NLS-1$
142 
143 	/**
144 	 * The client requested that the whole response be multiplexed, with
145 	 * each non-flush and non-delim pkt prefixed by a sideband designator.
146 	 *
147 	 * @since 5.5
148 	 */
149 	public static final String OPTION_SIDEBAND_ALL = "sideband-all"; //$NON-NLS-1$
150 
151 	/**
152 	 * The server waits for client to send "done" before sending any packs back.
153 	 *
154 	 * @since 5.13
155 	 */
156 	public static final String OPTION_WAIT_FOR_DONE = "wait-for-done"; //$NON-NLS-1$
157 
158 	/**
159 	 * The client supports atomic pushes. If this option is used, the server
160 	 * will update all refs within one atomic transaction.
161 	 *
162 	 * @since 3.6
163 	 */
164 	public static final String CAPABILITY_ATOMIC = "atomic"; //$NON-NLS-1$
165 
166 	/**
167 	 * The client expects less noise, e.g. no progress.
168 	 *
169 	 * @since 4.0
170 	 */
171 	public static final String CAPABILITY_QUIET = "quiet"; //$NON-NLS-1$
172 
173 	/**
174 	 * The client expects a status report after the server processes the pack.
175 	 *
176 	 * @since 3.2
177 	 */
178 	public static final String CAPABILITY_REPORT_STATUS = "report-status"; //$NON-NLS-1$
179 
180 	/**
181 	 * The server supports deleting refs.
182 	 *
183 	 * @since 3.2
184 	 */
185 	public static final String CAPABILITY_DELETE_REFS = "delete-refs"; //$NON-NLS-1$
186 
187 	/**
188 	 * The server supports packs with OFS deltas.
189 	 *
190 	 * @since 3.2
191 	 */
192 	public static final String CAPABILITY_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$
193 
194 	/**
195 	 * The client supports using the 64K side-band for progress messages.
196 	 *
197 	 * @since 3.2
198 	 */
199 	public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$
200 
201 	/**
202 	 * The server allows recording of push certificates.
203 	 *
204 	 * @since 4.0
205 	 */
206 	public static final String CAPABILITY_PUSH_CERT = "push-cert"; //$NON-NLS-1$
207 
208 	/**
209 	 * Implementation name and version of the client or server.
210 	 *
211 	 * @since 4.0
212 	 */
213 	public static final String OPTION_AGENT = "agent"; //$NON-NLS-1$
214 
215 	/**
216 	 * The server supports the receiving of push options.
217 	 *
218 	 * @since 4.5
219 	 */
220 	public static final String CAPABILITY_PUSH_OPTIONS = "push-options"; //$NON-NLS-1$
221 
222 	/**
223 	 * The server supports the client specifying ref names.
224 	 *
225 	 * @since 5.1
226 	 */
227 	public static final String CAPABILITY_REF_IN_WANT = "ref-in-want"; //$NON-NLS-1$
228 
229 	/**
230 	 * The server supports arbitrary options
231 	 *
232 	 * @since 5.2
233 	 */
234 	public static final String CAPABILITY_SERVER_OPTION = "server-option"; //$NON-NLS-1$
235 
236 	/**
237 	 * The server supports the receiving of shallow options.
238 	 *
239 	 * @since 6.3
240 	 */
241 	public static final String CAPABILITY_SHALLOW = "shallow"; //$NON-NLS-1$
242 
243 	/**
244 	 * Option for passing application-specific options to the server.
245 	 *
246 	 * @since 5.2
247 	 */
248 	public static final String OPTION_SERVER_OPTION = "server-option"; //$NON-NLS-1$
249 
250 	/**
251 	 * The server supports listing refs using protocol v2.
252 	 *
253 	 * @since 5.0
254 	 */
255 	public static final String COMMAND_LS_REFS = "ls-refs"; //$NON-NLS-1$
256 
257 	/**
258 	 * The server supports fetch using protocol v2.
259 	 *
260 	 * @since 5.0
261 	 */
262 	public static final String COMMAND_FETCH = "fetch"; //$NON-NLS-1$
263 
264 	/**
265 	 * The server supports the object-info capability.
266 	 *
267 	 * @since 5.13
268 	 */
269 	public static final String COMMAND_OBJECT_INFO = "object-info"; //$NON-NLS-1$
270 
271 	/**
272 	 * HTTP header to set by clients to request a specific git protocol version
273 	 * in the HTTP transport.
274 	 *
275 	 * @since 5.11
276 	 */
277 	public static final String PROTOCOL_HEADER = "Git-Protocol"; //$NON-NLS-1$
278 
279 	/**
280 	 * Environment variable to set by clients to request a specific git protocol
281 	 * in the file:// and ssh:// transports.
282 	 *
283 	 * @since 5.11
284 	 */
285 	public static final String PROTOCOL_ENVIRONMENT_VARIABLE = "GIT_PROTOCOL"; //$NON-NLS-1$
286 
287 	/**
288 	 * Protocol V2 ref advertisement attribute containing the peeled object id
289 	 * for annotated tags.
290 	 *
291 	 * @since 5.11
292 	 */
293 	public static final String REF_ATTR_PEELED = "peeled:"; //$NON-NLS-1$
294 
295 	/**
296 	 * Protocol V2 ref advertisement attribute containing the name of the ref
297 	 * for symbolic refs.
298 	 *
299 	 * @since 5.11
300 	 */
301 	public static final String REF_ATTR_SYMREF_TARGET = "symref-target:"; //$NON-NLS-1$
302 
303 	/**
304 	 * Protocol V2 acknowledgments section header.
305 	 *
306 	 * @since 5.11
307 	 */
308 	public static final String SECTION_ACKNOWLEDGMENTS = "acknowledgments"; //$NON-NLS-1$
309 
310 	/**
311 	 * Protocol V2 packfile section header.
312 	 *
313 	 * @since 5.11
314 	 */
315 	public static final String SECTION_PACKFILE = "packfile"; //$NON-NLS-1$
316 
317 	/**
318 	 * Protocol V2 shallow-info section header.
319 	 *
320 	 * @since 6.3
321 	 */
322 	public static final String SECTION_SHALLOW_INFO = "shallow-info"; //$NON-NLS-1$
323 
324 	/**
325 	 * Protocol announcement for protocol version 1. This is the same as V0,
326 	 * except for this initial line.
327 	 *
328 	 * @since 5.11
329 	 */
330 	public static final String VERSION_1 = "version 1"; //$NON-NLS-1$
331 
332 	/**
333 	 * Protocol announcement for protocol version 2.
334 	 *
335 	 * @since 5.11
336 	 */
337 	public static final String VERSION_2 = "version 2"; //$NON-NLS-1$
338 
339 	/**
340 	 * Protocol request for protocol version 2.
341 	 *
342 	 * @since 5.11
343 	 */
344 	public static final String VERSION_2_REQUEST = "version=2"; //$NON-NLS-1$
345 
346 	/**
347 	 * The flush packet.
348 	 *
349 	 * @since 6.3
350 	 */
351 	public static final String PACKET_FLUSH = "0000"; //$NON-NLS-1$
352 
353 	/**
354 	 * An alias for {@link #PACKET_FLUSH}. "Flush" is the name used in the C git
355 	 * documentation; the Java implementation calls this "end" in several
356 	 * places.
357 	 *
358 	 * @since 6.3
359 	 */
360 	public static final String PACKET_END = PACKET_FLUSH;
361 
362 	/**
363 	 * The delimiter packet in protocol V2.
364 	 *
365 	 * @since 6.3
366 	 */
367 	public static final String PACKET_DELIM = "0001"; //$NON-NLS-1$
368 
369 	/**
370 	 * A "deepen" packet beginning.
371 	 *
372 	 * @since 6.3
373 	 */
374 	public static final String PACKET_DEEPEN = "deepen "; //$NON-NLS-1$
375 
376 	/**
377 	 * A "deepen-not" packet beginning.
378 	 *
379 	 * @since 6.3
380 	 */
381 	public static final String PACKET_DEEPEN_NOT = "deepen-not "; //$NON-NLS-1$
382 
383 	/**
384 	 * A "deepen-since" packet beginning.
385 	 *
386 	 * @since 6.3
387 	 */
388 	public static final String PACKET_DEEPEN_SINCE = "deepen-since "; //$NON-NLS-1$
389 
390 	/**
391 	 * An "ACK" packet beginning.
392 	 *
393 	 * @since 6.3
394 	 */
395 	public static final String PACKET_ACK = "ACK "; //$NON-NLS-1$
396 
397 	/**
398 	 * A "done" packet beginning.
399 	 *
400 	 * @since 6.3
401 	 */
402 	public static final String PACKET_DONE = "done"; //$NON-NLS-1$
403 
404 	/**
405 	 * A "ERR" packet beginning.
406 	 *
407 	 * @since 6.3
408 	 */
409 	public static final String PACKET_ERR = "ERR "; //$NON-NLS-1$
410 
411 	/**
412 	 * A "have" packet beginning.
413 	 *
414 	 * @since 6.3
415 	 */
416 	public static final String PACKET_HAVE = "have "; //$NON-NLS-1$
417 
418 	/**
419 	 * A "shallow" packet beginning.
420 	 *
421 	 * @since 6.3
422 	 */
423 	public static final String PACKET_SHALLOW = OPTION_SHALLOW + ' ';
424 
425 	/**
426 	 * A "shallow" packet beginning.
427 	 *
428 	 * @since 6.3
429 	 */
430 	public static final String PACKET_UNSHALLOW = "unshallow "; //$NON-NLS-1$
431 
432 	/**
433 	 * A "want" packet beginning.
434 	 *
435 	 * @since 6.3
436 	 */
437 	public static final String PACKET_WANT = "want "; //$NON-NLS-1$
438 
439 	/**
440 	 * A "want-ref" packet beginning.
441 	 *
442 	 * @since 6.3
443 	 */
444 	public static final String PACKET_WANT_REF = OPTION_WANT_REF + ' ';
445 
446 	enum MultiAck {
447 		OFF, CONTINUE, DETAILED;
448 	}
449 
450 	private GitProtocolConstants() {
451 	}
452 }