blob: 2cf7735be479e6863f4e373bd7cf7794624e0094 [file] [log] [blame]
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +02001gitprotocol-capabilities(5)
2===========================
3
4NAME
5----
6gitprotocol-capabilities - Protocol v0 and v1 capabilities
7
8SYNOPSIS
9--------
10[verse]
11<over-the-wire-protocol>
12
13DESCRIPTION
14-----------
Scott Chaconb31222c2009-11-03 21:58:23 -080015
Josh Steadmon90503a22019-02-19 16:32:26 -080016NOTE: this document describes capabilities for versions 0 and 1 of the pack
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +020017protocol. For version 2, please refer to the linkgit:gitprotocol-v2[5]
Josh Steadmon90503a22019-02-19 16:32:26 -080018doc.
19
Scott Chaconb31222c2009-11-03 21:58:23 -080020Servers SHOULD support all capabilities defined in this document.
21
22On the very first line of the initial server response of either
23receive-pack and upload-pack the first reference is followed by
24a NUL byte and then a list of space delimited server capabilities.
25These allow the server to declare what it can and cannot support
26to the client.
27
28Client will then send a space separated list of capabilities it wants
29to be in effect. The client MUST NOT ask for capabilities the server
30did not say it supports.
31
32Server MUST diagnose and abort if capabilities it does not understand
Elijah Newrence14cc02023-10-08 06:45:09 +000033were sent. Server MUST NOT ignore capabilities that client requested
Scott Chaconb31222c2009-11-03 21:58:23 -080034and server advertised. As a consequence of these rules, server MUST
35NOT advertise capabilities it does not understand.
36
Jiang Xinb9130752020-08-27 11:45:47 -040037The 'atomic', 'report-status', 'report-status-v2', 'delete-refs', 'quiet',
38and 'push-cert' capabilities are sent and recognized by the receive-pack
39(push to server) process.
Scott Chaconb31222c2009-11-03 21:58:23 -080040
Jeff King9354b9a2013-07-24 04:01:59 -040041The 'ofs-delta' and 'side-band-64k' capabilities are sent and recognized
Josh Steadmonf5cdbe42020-11-11 15:29:24 -080042by both upload-pack and receive-pack protocols. The 'agent' and 'session-id'
43capabilities may optionally be sent in both protocols.
Scott Chaconb31222c2009-11-03 21:58:23 -080044
45All other capabilities are only recognized by the upload-pack (fetch
46from server) process.
47
48multi_ack
49---------
50
51The 'multi_ack' capability allows the server to return "ACK obj-id
52continue" as soon as it finds a commit that it can use as a common
53base, between the client's wants and the client's have set.
54
55By sending this early, the server can potentially head off the client
56from walking any further down that particular branch of the client's
57repository history. The client may still need to walk down other
58branches, sending have lines for those, until the server has a
59complete cut across the DAG, or the client has said "done".
60
61Without multi_ack, a client sends have lines in --date-order until
62the server has found a common base. That means the client will send
63have lines that are already known by the server to be common, because
Elijah Newrencf6cac22023-10-08 06:45:03 +000064they overlap in time with another branch on which the server hasn't found
65a common base yet.
Scott Chaconb31222c2009-11-03 21:58:23 -080066
67For example suppose the client has commits in caps that the server
68doesn't and the server has commits in lower case that the client
69doesn't, as in the following diagram:
70
71 +---- u ---------------------- x
72 / +----- y
73 / /
74 a -- b -- c -- d -- E -- F
75 \
76 +--- Q -- R -- S
77
78If the client wants x,y and starts out by saying have F,S, the server
79doesn't know what F,S is. Eventually the client says "have d" and
80the server sends "ACK d continue" to let the client know to stop
Ralf Wildenhues6a5d0b02010-01-31 14:24:39 +010081walking down that line (so don't send c-b-a), but it's not done yet,
Scott Chaconb31222c2009-11-03 21:58:23 -080082it needs a base for x. The client keeps going with S-R-Q, until a
83gets reached, at which point the server has a clear base and it all
84ends.
85
86Without multi_ack the client would have sent that c-b-a chain anyway,
87interleaved with S-R-Q.
88
Nguyễn Thái Ngọc Duy087e3472014-02-06 22:10:37 +070089multi_ack_detailed
90------------------
Elijah Newren0a4f0512023-10-08 06:45:17 +000091This is an extension of multi_ack that permits the client to better
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +020092understand the server's in-memory state. See linkgit:gitprotocol-pack[5],
Nguyễn Thái Ngọc Duy087e3472014-02-06 22:10:37 +070093section "Packfile Negotiation" for more information.
94
Nguyễn Thái Ngọc Duyc9cd60f2014-02-06 22:10:38 +070095no-done
96-------
97This capability should only be used with the smart HTTP protocol. If
98multi_ack_detailed and no-done are both present, then the sender is
99free to immediately send a pack following its first "ACK obj-id ready"
100message.
101
102Without no-done in the smart HTTP protocol, the server session would
103end and the client has to make another trip to send "done" before
104the server can send the pack. no-done removes the last round and
105thus slightly reduces latency.
106
Scott Chaconb31222c2009-11-03 21:58:23 -0800107thin-pack
108---------
109
Carlos Martín Nieto1ba98a72013-11-23 17:07:55 +0100110A thin pack is one with deltas which reference base objects not
111contained within the pack (but are known to exist at the receiving
112end). This can reduce the network traffic significantly, but it
113requires the receiving end to know how to "thicken" these packs by
114adding the missing bases to the pack.
Scott Chaconb31222c2009-11-03 21:58:23 -0800115
Carlos Martín Nieto1ba98a72013-11-23 17:07:55 +0100116The upload-pack server advertises 'thin-pack' when it can generate
117and send a thin pack. A client requests the 'thin-pack' capability
118when it understands how to "thicken" it, notifying the server that
119it can receive such a pack. A client MUST NOT request the
120'thin-pack' capability if it cannot turn a thin pack into a
121self-contained pack.
122
123Receive-pack, on the other hand, is assumed by default to be able to
124handle thin packs, but can ask the client not to use the feature by
125advertising the 'no-thin' capability. A client MUST NOT send a thin
126pack if the server advertises the 'no-thin' capability.
127
128The reasons for this asymmetry are historical. The receive-pack
129program did not exist until after the invention of thin packs, so
130historically the reference implementation of receive-pack always
131understood thin packs. Adding 'no-thin' later allowed receive-pack
132to disable the feature in a backwards-compatible manner.
Scott Chaconb31222c2009-11-03 21:58:23 -0800133
134
135side-band, side-band-64k
136------------------------
137
Elijah Newrencf6cac22023-10-08 06:45:03 +0000138This capability means that the server can send, and the client can understand, multiplexed
Scott Chaconb31222c2009-11-03 21:58:23 -0800139progress reports and error info interleaved with the packfile itself.
140
141These two options are mutually exclusive. A modern client always
142favors 'side-band-64k'.
143
144Either mode indicates that the packfile data will be streamed broken
145up into packets of up to either 1000 bytes in the case of 'side_band',
146or 65520 bytes in the case of 'side_band_64k'. Each packet is made up
147of a leading 4-byte pkt-line length of how much data is in the packet,
148followed by a 1-byte stream code, followed by the actual data.
149
150The stream code can be one of:
151
152 1 - pack data
153 2 - progress messages
154 3 - fatal error message just before stream aborts
155
156The "side-band-64k" capability came about as a way for newer clients
157that can handle much larger packets to request packets that are
158actually crammed nearly full, while maintaining backward compatibility
159for the older clients.
160
161Further, with side-band and its up to 1000-byte messages, it's actually
162999 bytes of payload and 1 byte for the stream code. With side-band-64k,
163same deal, you have up to 65519 bytes of data and 1 byte for the stream
164code.
165
Elijah Newrencf6cac22023-10-08 06:45:03 +0000166The client MUST send only one of "side-band" and "side-
167band-64k". The server MUST diagnose it as an error if client requests
Scott Chaconb31222c2009-11-03 21:58:23 -0800168both.
169
170ofs-delta
171---------
172
Elijah Newrencf6cac22023-10-08 06:45:03 +0000173The server can send, and the client can understand, PACKv2 with delta referring to
Scott Chaconb31222c2009-11-03 21:58:23 -0800174its base by position in pack rather than by an obj-id. That is, they can
175send/read OBJ_OFS_DELTA (aka type 6) in a packfile.
176
Jeff Kingaf608262013-07-24 04:03:13 -0400177agent
178-----
179
180The server may optionally send a capability of the form `agent=X` to
181notify the client that the server is running version `X`. The client may
182optionally return its own agent string by responding with an `agent=Y`
183capability (but it MUST NOT do so if the server did not mention the
184agent capability). The `X` and `Y` strings may contain any printable
185ASCII characters except space (i.e., the byte range 32 < x < 127), and
186are typically of the form "package/version" (e.g., "git/1.8.3.1"). The
187agent strings are purely informative for statistics and debugging
Thomas Ackermannf745acb2014-11-03 21:37:07 +0100188purposes, and MUST NOT be used to programmatically assume the presence
Jeff Kingaf608262013-07-24 04:03:13 -0400189or absence of particular features.
190
brian m. carlsonb8615c32020-05-13 00:53:42 +0000191object-format
192-------------
193
194This capability, which takes a hash algorithm as an argument, indicates
195that the server supports the given hash algorithms. It may be sent
196multiple times; if so, the first one given is the one used in the ref
197advertisement.
198
199When provided by the client, this indicates that it intends to use the
200given hash algorithm to communicate. The algorithm provided must be one
201that the server supports.
202
203If this capability is not provided, it is assumed that the only
204supported algorithm is SHA-1.
205
Josh Steadmon90503a22019-02-19 16:32:26 -0800206symref
207------
208
209This parameterized capability is used to inform the receiver which symbolic ref
210points to which ref; for example, "symref=HEAD:refs/heads/master" tells the
211receiver that HEAD points to master. This capability can be repeated to
212represent multiple symrefs.
213
214Servers SHOULD include this capability for the HEAD symref if it is one of the
215refs being sent.
216
217Clients MAY use the parameters from this capability to select the proper initial
218branch when cloning a repository.
219
Scott Chaconb31222c2009-11-03 21:58:23 -0800220shallow
221-------
222
223This capability adds "deepen", "shallow" and "unshallow" commands to
224the fetch-pack/upload-pack protocol so clients can request shallow
225clones.
226
Nguyễn Thái Ngọc Duy569e5542016-06-12 17:53:58 +0700227deepen-since
228------------
229
230This capability adds "deepen-since" command to fetch-pack/upload-pack
231protocol so the client can request shallow clones that are cut at a
232specific time, instead of depth. Internally it's equivalent of doing
233"rev-list --max-age=<timestamp>" on the server side. "deepen-since"
234cannot be used with "deepen".
235
Nguyễn Thái Ngọc Duy269a7a82016-06-12 17:54:03 +0700236deepen-not
237----------
238
239This capability adds "deepen-not" command to fetch-pack/upload-pack
240protocol so the client can request shallow clones that are cut at a
241specific revision, instead of depth. Internally it's equivalent of
242doing "rev-list --not <rev>" on the server side. "deepen-not"
243cannot be used with "deepen", but can be used with "deepen-since".
244
Nguyễn Thái Ngọc Duycccf74e2016-06-12 17:54:09 +0700245deepen-relative
246---------------
247
248If this capability is requested by the client, the semantics of
249"deepen" command is changed. The "depth" argument is the depth from
250the current shallow boundary, instead of the depth from remote refs.
251
Scott Chaconb31222c2009-11-03 21:58:23 -0800252no-progress
253-----------
254
Elijah Newrencf6cac22023-10-08 06:45:03 +0000255The client was started with "git clone -q" or something similar, and doesn't
Scott Chaconb31222c2009-11-03 21:58:23 -0800256want that side band 2. Basically the client just says "I do not
257wish to receive stream 2 on sideband, so do not send it to me, and if
258you did, I will drop it on the floor anyway". However, the sideband
259channel 3 is still used for error responses.
260
261include-tag
262-----------
263
264The 'include-tag' capability is about sending annotated tags if we are
265sending objects they point to. If we pack an object to the client, and
266a tag object points exactly at that object, we pack the tag object too.
267In general this allows a client to get all new annotated tags when it
268fetches a branch, in a single network connection.
269
270Clients MAY always send include-tag, hardcoding it into a request when
271the server advertises this capability. The decision for a client to
272request include-tag only has to do with the client's desires for tag
273data, whether or not a server had advertised objects in the
274refs/tags/* namespace.
275
Elijah Newren384f7d12023-10-08 06:45:05 +0000276Servers MUST pack the tags if their referent is packed and the client
Scott Chaconb31222c2009-11-03 21:58:23 -0800277has requested include-tags.
278
279Clients MUST be prepared for the case where a server has ignored
280include-tag and has not actually sent tags in the pack. In such
281cases the client SHOULD issue a subsequent fetch to acquire the tags
282that include-tag would have otherwise given the client.
283
284The server SHOULD send include-tag, if it supports it, regardless
285of whether or not there are tags available.
286
287report-status
288-------------
289
Jeff King9a621ad2013-07-24 04:01:21 -0400290The receive-pack process can receive a 'report-status' capability,
Scott Chaconb31222c2009-11-03 21:58:23 -0800291which tells it that the client wants a report of what happened after
292a packfile upload and reference update. If the pushing client requests
293this capability, after unpacking and updating references the server
294will respond with whether the packfile unpacked successfully and if
295each reference was updated successfully. If any of those were not
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +0200296successful, it will send back an error message. See linkgit:gitprotocol-pack[5]
Scott Chaconb31222c2009-11-03 21:58:23 -0800297for example messages.
298
Jiang Xinb9130752020-08-27 11:45:47 -0400299report-status-v2
300----------------
301
302Capability 'report-status-v2' extends capability 'report-status' by
303adding new "option" directives in order to support reference rewritten by
304the "proc-receive" hook. The "proc-receive" hook may handle a command
305for a pseudo-reference which may create or update a reference with
306different name, new-oid, and old-oid. While the capability
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +0200307'report-status' cannot report for such case. See linkgit:gitprotocol-pack[5]
Jiang Xinb9130752020-08-27 11:45:47 -0400308for details.
309
Scott Chaconb31222c2009-11-03 21:58:23 -0800310delete-refs
311-----------
312
313If the server sends back the 'delete-refs' capability, it means that
Ralf Wildenhues6a5d0b02010-01-31 14:24:39 +0100314it is capable of accepting a zero-id value as the target
Scott Chaconb31222c2009-11-03 21:58:23 -0800315value of a reference update. It is not sent back by the client, it
316simply informs the client that it can be sent zero-id values
317to delete references.
Jeff King69fb9602013-07-24 04:03:43 -0400318
319quiet
320-----
321
322If the receive-pack server advertises the 'quiet' capability, it is
323capable of silencing human-readable progress output which otherwise may
324be shown when processing the received pack. A send-pack client should
325respond with the 'quiet' capability to suppress server-side progress
326reporting if the local progress reporting is also being suppressed
327(e.g., via `push -q`, or if stderr does not go to a tty).
Nguyễn Thái Ngọc Duy4acbe912013-07-26 18:01:54 +0700328
Ronnie Sahlberg1b70fe52015-01-07 19:23:20 -0800329atomic
330------
331
332If the server sends the 'atomic' capability it is capable of accepting
333atomic pushes. If the pushing client requests this capability, the server
334will update the refs in one atomic transaction. Either all refs are
335updated or none.
336
Stefan Bellerc714e452016-07-14 14:49:46 -0700337push-options
338------------
339
340If the server sends the 'push-options' capability it is able to accept
341push options after the update commands have been sent, but before the
342packfile is streamed. If the pushing client requests this capability,
343the server will pass the options to the pre- and post- receive hooks
344that process this push request.
345
Nguyễn Thái Ngọc Duy4acbe912013-07-26 18:01:54 +0700346allow-tip-sha1-in-want
347----------------------
348
349If the upload-pack server advertises this capability, fetch-pack may
Martin Ågren0756e612020-08-15 18:06:01 +0200350send "want" lines with object names that exist at the server but are not
351advertised by upload-pack. For historical reasons, the name of this
352capability contains "sha1". Object names are always given using the
353object format negotiated through the 'object-format' capability.
Junio C Hamano4adf5692014-08-18 14:38:45 -0700354
Fredrik Medley68ee6282015-05-21 22:23:39 +0200355allow-reachable-sha1-in-want
356----------------------------
357
358If the upload-pack server advertises this capability, fetch-pack may
Martin Ågren0756e612020-08-15 18:06:01 +0200359send "want" lines with object names that exist at the server but are not
360advertised by upload-pack. For historical reasons, the name of this
361capability contains "sha1". Object names are always given using the
362object format negotiated through the 'object-format' capability.
Fredrik Medley68ee6282015-05-21 22:23:39 +0200363
Junio C Hamanob89363e2014-08-21 16:45:30 -0700364push-cert=<nonce>
365-----------------
Junio C Hamano4adf5692014-08-18 14:38:45 -0700366
367The receive-pack server that advertises this capability is willing
Junio C Hamanob89363e2014-08-21 16:45:30 -0700368to accept a signed push certificate, and asks the <nonce> to be
369included in the push certificate. A send-pack client MUST NOT
Junio C Hamano4adf5692014-08-18 14:38:45 -0700370send a push-cert packet unless the receive-pack server advertises
371this capability.
Jeff Hostetler10ac85c2017-12-08 15:58:39 +0000372
373filter
374------
375
376If the upload-pack server advertises the 'filter' capability,
377fetch-pack may send "filter" commands to request a partial clone
378or partial fetch and request that the server omit various objects
379from the packfile.
Josh Steadmonf5cdbe42020-11-11 15:29:24 -0800380
Jean-Noël Avila2162f9f2023-12-25 21:21:26 +0000381session-id=<session-id>
Josh Steadmonf5cdbe42020-11-11 15:29:24 -0800382-----------------------
383
384The server may advertise a session ID that can be used to identify this process
385across multiple requests. The client may advertise its own session ID back to
386the server as well.
387
388Session IDs should be unique to a given process. They must fit within a
389packet-line, and must not contain non-printable or whitespace characters. The
390current implementation uses trace2 session IDs (see
Todd Zullinger086eaab2022-09-16 02:23:02 -0400391link:technical/api-trace2.html[api-trace2] for details), but this may change
392and users of the session ID should not rely on this fact.
Ævar Arnfjörð Bjarmason5db92102022-08-04 18:28:36 +0200393
394GIT
395---
396Part of the linkgit:git[1] suite