2 .\" Title: gitprotocol-v2
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.45.2.648.g1e1586e4ed
10 .TH "GITPROTOCOL\-V2" "5" "2024\-06\-24" "Git 2\&.45\&.2\&.648\&.g1e1586" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 gitprotocol-v2 \- Git Wire Protocol, Version 2
35 <over\-the\-wire\-protocol>
40 This document presents a specification for a version 2 of Git\(cqs wire protocol\&. Protocol v2 will improve upon v1 in the following ways:
50 Instead of multiple service names, multiple commands will be supported by a single service
61 Easily extendable as capabilities are moved into their own section of the protocol, no longer being hidden behind a NUL byte and limited by the size of a pkt\-line
72 Separate out other information hidden behind NUL bytes (e\&.g\&. agent string as a capability and symrefs can be requested using
84 Reference advertisement will be omitted unless explicitly requested
95 ls\-refs command to explicitly request some refs
106 Designed with http and stateless\-rpc in mind\&. With clear flush semantics the http remote helper can simply act as a proxy
109 In protocol v2 communication is command oriented\&. When first contacting a server a list of capabilities will be advertised\&. Some of these capabilities will be commands which a client can request be executed\&. Once a command has completed, a client can reuse the connection and request that other commands be executed\&.
110 .SH "PACKET\-LINE FRAMING"
112 All communication is done using packet\-line framing, just as in v1\&. See \fBgitprotocol-pack\fR(5) and \fBgitprotocol-common\fR(5) for more information\&.
114 In protocol v2 these special packets will have the following semantics:
125 Flush Packet (flush\-pkt) \- indicates the end of a message
137 Delimiter Packet (delim\-pkt) \- separates sections of a message
149 Response End Packet (response\-end\-pkt) \- indicates the end of a response for stateless connections
151 .SH "INITIAL CLIENT REQUEST"
153 In general a client can request to speak protocol v2 by sending \fBversion=2\fR through the respective side\-channel for the transport being used which inevitably sets \fBGIT_PROTOCOL\fR\&. More information can be found in \fBgitprotocol-pack\fR(5) and \fBgitprotocol-http\fR(5), as well as the \fBGIT_PROTOCOL\fR definition in \fBgit\&.txt\fR\&. In all cases the response from the server is the capability advertisement\&.
156 When using the git:// transport, you can request to use protocol v2 by sending "version=2" as an extra parameter:
162 003egit\-upload\-pack /project\&.git\e0host=myserver\&.com\e0\e0version=2\e0
167 .SS "SSH and File Transport"
169 When using either the ssh:// or file:// transport, the GIT_PROTOCOL environment variable must be set explicitly to include "version=2"\&. The server may need to be configured to allow this environment variable to pass\&.
172 When using the http:// or https:// transport a client makes a "smart" info/refs request as described in \fBgitprotocol-http\fR(5) and requests that v2 be used by supplying "version=2" in the \fBGit\-Protocol\fR header\&.
178 C: GET $GIT_URL/info/refs?service=git\-upload\-pack HTTP/1\&.0
179 C: Git\-Protocol: version=2
185 A v2 server would reply:
196 S: <capability\-advertisement>
202 Subsequent requests are then made directly to the service \fB$GIT_URL/git\-upload\-pack\fR\&. (This works the same for git\-receive\-pack)\&.
204 Uses the \fB\-\-http\-backend\-info\-refs\fR option to \fBgit-upload-pack\fR(1)\&.
206 The server may need to be configured to pass this header\(cqs contents via the \fBGIT_PROTOCOL\fR variable\&. See the discussion in \fBgit\-http\-backend\&.txt\fR\&.
207 .SH "CAPABILITY ADVERTISEMENT"
209 A server which decides to communicate (based on a request from a client) using protocol version 2, notifies the client by sending a version string in its initial response followed by an advertisement of its capabilities\&. Each capability is a key with an optional value\&. Clients must ignore all unknown keys\&. Semantics of unknown values are left to the definition of each key\&. Some capabilities will describe commands which can be requested to be executed by the client\&.
215 capability\-advertisement = protocol\-version
227 protocol\-version = PKT\-LINE("version 2" LF)
228 capability\-list = *capability
229 capability = PKT\-LINE(key[=value] LF)
239 key = 1*(ALPHA | DIGIT | "\-_")
240 value = 1*(ALPHA | DIGIT | " \-_\&.,?\e/{}[]()<>!@#$%^&*+=:;")
245 .SH "COMMAND REQUEST"
247 After receiving the capability advertisement, a client can then issue a request to select the command it wants with any particular capabilities or arguments\&. There is then an optional section where the client can provide any command specific parameters or queries\&. Only a single command can be requested at a time\&.
253 request = empty\-request | command\-request
254 empty\-request = flush\-pkt
255 command\-request = command
260 command = PKT\-LINE("command=" key LF)
261 command\-args = *command\-specific\-arg
271 command\-specific\-args are packet line framed arguments defined by
272 each individual command\&.
278 The server will then check to ensure that the client\(cqs request is comprised of a valid command as well as valid capabilities which were advertised\&. If the request is valid the server will then execute the command\&. A server MUST wait till it has received the client\(cqs entire request before issuing a response\&. The format of the response is determined by the command being executed, but in all cases a flush\-pkt indicates the end of the response\&.
280 When a command has finished, and the client has received the entire response from the server, a client can either request that another command be executed or can terminate the connection\&. A client may optionally send an empty request consisting of just a flush\-pkt to indicate that no more requests will be made\&.
283 There are two different types of capabilities: normal capabilities, which can be used to convey information or alter the behavior of a request, and commands, which are the core actions that a client wants to perform (fetch, push, etc)\&.
285 Protocol version 2 is stateless by default\&. This means that all commands must only last a single round and be stateless from the perspective of the server side, unless the client has requested a capability indicating that state should be maintained by the server\&. Clients MUST NOT require state management on the server side in order to function correctly\&. This permits simple round\-robin load\-balancing on the server side, without needing to worry about state management\&.
288 The server can advertise the \fBagent\fR capability with a value \fBX\fR (in the form \fBagent=X\fR) to notify the client that the server is running version \fBX\fR\&. The client may optionally send its own agent string by including the \fBagent\fR capability with a value \fBY\fR (in the form \fBagent=Y\fR) in its request to the server (but it MUST NOT do so if the server did not advertise the agent capability)\&. The \fBX\fR and \fBY\fR strings may contain any printable ASCII characters except space (i\&.e\&., the byte range 32 < x < 127), and are typically of the form "package/version" (e\&.g\&., "git/1\&.8\&.3\&.1")\&. The agent strings are purely informative for statistics and debugging purposes, and MUST NOT be used to programmatically assume the presence or absence of particular features\&.
291 \fBls\-refs\fR is the command used to request a reference advertisement in v2\&. Unlike the current reference advertisement, ls\-refs takes in arguments which can be used to limit the refs sent from the server\&.
293 Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature\-1> <feature\-2>"
295 ls\-refs takes in the following arguments:
302 In addition to the object pointed by it, show the underlying ref
303 pointed by it when showing a symbolic ref\&.
307 When specified, only references having a prefix matching one of
308 the provided prefixes are displayed\&. Multiple instances may be
309 given, in which case references matching any prefix will be
310 shown\&. Note that this is purely for optimization; a server MAY
311 show refs not matching the prefix if it chooses, and clients
312 should filter the result themselves\&.
318 If the \fIunborn\fR feature is advertised the following argument can be included in the client\(cqs request\&.
325 The server will send information about HEAD even if it is a symref
326 pointing to an unborn branch in the form "unborn HEAD
327 symref\-target:<target>"\&.
333 The output of ls\-refs is as follows:
341 obj\-id\-or\-unborn = (obj\-id | "unborn")
342 ref = PKT\-LINE(obj\-id\-or\-unborn SP refname *(SP ref\-attribute) LF)
343 ref\-attribute = (symref | peeled)
344 symref = "symref\-target:" symref\-target
345 peeled = "peeled:" obj\-id
352 \fBfetch\fR is the command used to fetch a packfile in v2\&. It can be looked at as a modified version of the v1 fetch where the ref\-advertisement is stripped out (since the \fBls\-refs\fR command fills that role) and the message format is tweaked to eliminate redundancies and permit easy addition of future extensions\&.
354 Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature\-1> <feature\-2>"
356 A \fBfetch\fR request can take the following arguments:
363 Indicates to the server an object which the client wants to
364 retrieve\&. Wants can be anything and are not limited to
365 advertised objects\&.
376 Indicates to the server an object which the client has locally\&.
377 This allows the server to make a packfile which only contains
378 the objects that the client needs\&. Multiple \*(Aqhave\*(Aq lines can be
390 Indicates to the server that negotiation should terminate (or
391 not even begin if performing a clone) and that the server should
392 use the information supplied in the request to construct the
404 Request that a thin pack be sent, which is a pack with deltas
405 which reference base objects not contained within the pack (but
406 are known to exist at the receiving end)\&. This can reduce the
407 network traffic significantly, but it requires the receiving end
408 to know how to "thicken" these packs by adding the missing bases
420 Request that progress information that would normally be sent on
421 side\-band channel 2, during the packfile transfer, should not be
422 sent\&. However, the side\-band channel 3 is still used for error
434 Request that annotated tags should be sent if the objects they
435 point to are being sent\&.
446 Indicate that the client understands PACKv2 with delta referring
447 to its base by position in pack rather than by an oid\&. That is,
448 they can read OBJ_OFS_DELTA (aka type 6) in a packfile\&.
454 If the \fIshallow\fR feature is advertised the following arguments can be included in the clients request as well as the potential addition of the \fIshallow\-info\fR section in the server\(cqs response as explained below\&.
461 A client must notify the server of all commits for which it only
462 has shallow copies (meaning that it doesn\*(Aqt have the parents of
463 a commit) by supplying a \*(Aqshallow <oid>\*(Aq line for each such
464 object so that the server is aware of the limitations of the
465 client\*(Aqs history\&. This is so that the server is aware that the
466 client may not have all objects reachable from such commits\&.
477 Requests that the fetch/clone should be shallow having a commit
478 depth of <depth> relative to the remote side\&.
489 Requests that the semantics of the "deepen" command be changed
490 to indicate that the depth requested is relative to the client\*(Aqs
491 current shallow boundary, instead of relative to the requested
502 deepen\-since <timestamp>
503 Requests that the shallow clone/fetch should be cut at a
504 specific time, instead of depth\&. Internally it\*(Aqs equivalent to
505 doing "git rev\-list \-\-max\-age=<timestamp>"\&. Cannot be used with
517 Requests that the shallow clone/fetch should be cut at a
518 specific revision specified by \*(Aq<rev>\*(Aq, instead of a depth\&.
519 Internally it\*(Aqs equivalent of doing "git rev\-list \-\-not <rev>"\&.
520 Cannot be used with "deepen", but can be used with
527 If the \fIfilter\fR feature is advertised, the following argument can be included in the client\(cqs request:
533 filter <filter\-spec>
534 Request that various objects from the packfile be omitted
535 using one of several filtering techniques\&. These are intended
536 for use with partial clone and partial fetch operations\&. See
537 `rev\-list` for possible "filter\-spec" values\&. When communicating
538 with other processes, senders SHOULD translate scaled integers
539 (e\&.g\&. "1k") into a fully\-expanded form (e\&.g\&. "1024") to aid
540 interoperability with older receivers that may not understand
541 newly\-invented scaling suffixes\&. However, receivers SHOULD
542 accept the following suffixes: \*(Aqk\*(Aq, \*(Aqm\*(Aq, and \*(Aqg\*(Aq for 1024,
543 1048576, and 1073741824, respectively\&.
549 If the \fIref\-in\-want\fR feature is advertised, the following argument can be included in the client\(cqs request as well as the potential addition of the \fIwanted\-refs\fR section in the server\(cqs response as explained below\&.
556 Indicates to the server that the client wants to retrieve a
557 particular ref, where <ref> is the full name of a ref on the
558 server\&. It is a protocol error to send want\-ref for the
559 same ref more than once\&.
565 If the \fIsideband\-all\fR feature is advertised, the following argument can be included in the client\(cqs request:
572 Instruct the server to send the whole response multiplexed, not just
573 the packfile section\&. All non\-flush and non\-delim PKT\-LINE in the
574 response (not only in the packfile section) will then start with a byte
575 indicating its sideband (1, 2, or 3), and the server may send "0005\e2"
576 (a PKT\-LINE of sideband 2 with no payload) as a keepalive packet\&.
582 If the \fIpackfile\-uris\fR feature is advertised, the following argument can be included in the client\(cqs request as well as the potential addition of the \fIpackfile\-uris\fR section in the server\(cqs response as explained below\&. Note that at most one \fBpackfile\-uris\fR line can be sent to the server\&.
588 packfile\-uris <comma\-separated\-list\-of\-protocols>
589 Indicates to the server that the client is willing to receive
590 URIs of any of the given protocols in place of objects in the
591 sent packfile\&. Before performing the connectivity check, the
592 client should download from all given URIs\&. Currently, the
593 protocols supported are "http" and "https"\&.
599 If the \fIwait\-for\-done\fR feature is advertised, the following argument can be included in the client\(cqs request\&.
606 Indicates to the server that it should never send "ready", but
607 should wait for the client to say "done" before sending the
614 The response of \fBfetch\fR is broken into a number of sections separated by delimiter packets (0001), with each section beginning with its section header\&. Most sections are sent only when the packfile is sent\&.
620 output = acknowledgements flush\-pkt |
621 [acknowledgments delim\-pkt] [shallow\-info delim\-pkt]
622 [wanted\-refs delim\-pkt] [packfile\-uris delim\-pkt]
633 acknowledgments = PKT\-LINE("acknowledgments" LF)
636 ready = PKT\-LINE("ready" LF)
637 nak = PKT\-LINE("NAK" LF)
638 ack = PKT\-LINE("ACK" SP obj\-id LF)
648 shallow\-info = PKT\-LINE("shallow\-info" LF)
649 *PKT\-LINE((shallow | unshallow) LF)
650 shallow = "shallow" SP obj\-id
651 unshallow = "unshallow" SP obj\-id
661 wanted\-refs = PKT\-LINE("wanted\-refs" LF)
662 *PKT\-LINE(wanted\-ref LF)
663 wanted\-ref = obj\-id SP refname
673 packfile\-uris = PKT\-LINE("packfile\-uris" LF) *packfile\-uri
674 packfile\-uri = PKT\-LINE(40*(HEXDIGIT) SP *%x20\-ff LF)
684 packfile = PKT\-LINE("packfile" LF)
685 *PKT\-LINE(%x01\-03 *%x00\-ff)
695 acknowledgments section
696 * If the client determines that it is finished with negotiations by
697 sending a "done" line (thus requiring the server to send a packfile),
698 the acknowledgments sections MUST be omitted from the server\*(Aqs
713 Always begins with the section header "acknowledgments"
724 The server will respond with "NAK" if none of the object ids sent as have lines were common\&.
735 The server will respond with "ACK obj\-id" for all of the object ids sent as have lines which are common\&.
746 A response cannot have both "ACK" lines as well as a "NAK" line\&.
757 The server will respond with a "ready" line indicating that the server has found an acceptable common base and is ready to make and send a packfile (which will be found in the packfile section of the same response)
768 If the server has found a suitable cut point and has decided to send a "ready" line, then the server can decide to (as an optimization) omit any "ACK" lines it would have sent during its response\&. This is because the server will have already determined the objects it plans to send to the client and no further negotiation is needed\&.
774 shallow\-info section
775 * If the client has requested a shallow fetch/clone, a shallow
776 client requests a fetch or the server is shallow then the
777 server\*(Aqs response may include a shallow\-info section\&. The
778 shallow\-info section will be included if (due to one of the
779 above conditions) the server needs to inform the client of any
780 shallow boundaries or adjustments to the clients already
781 existing shallow boundaries\&.
796 Always begins with the section header "shallow\-info"
807 If a positive depth is requested, the server will compute the set of commits which are no deeper than the desired depth\&.
818 The server sends a "shallow obj\-id" line for each commit whose parents will not be sent in the following packfile\&.
829 The server sends an "unshallow obj\-id" line for each commit which the client has indicated is shallow, but is no longer shallow as a result of the fetch (due to its parents being sent in the following packfile)\&.
840 The server MUST NOT send any "unshallow" lines for anything which the client has not indicated was shallow as a part of its request\&.
847 * This section is only included if the client has requested a
848 ref using a \*(Aqwant\-ref\*(Aq line and if a packfile section is also
849 included in the response\&.
864 Always begins with the section header "wanted\-refs"\&.
875 The server will send a ref listing ("<oid> <refname>") for each reference requested using
888 The server MUST NOT send any refs which were not requested using
896 packfile\-uris section
897 * This section is only included if the client sent
898 \*(Aqpackfile\-uris\*(Aq and the server has at least one such URI to
914 Always begins with the section header "packfile\-uris"\&.
925 For each URI the server sends, it sends a hash of the pack\(cqs contents (as output by git index\-pack) followed by the URI\&.
936 The hashes are 40 hex characters long\&. When Git upgrades to a new hash algorithm, this might need to be updated\&. (It should match whatever index\-pack outputs after "pack\et" or "keep\et"\&.
943 * This section is only included if the client has sent \*(Aqwant\*(Aq
944 lines in its request and either requested that no more
945 negotiation be done by sending \*(Aqdone\*(Aq or if the server has
946 decided it has found a sufficient cut point to produce a
962 Always begins with the section header "packfile"
973 The transmission of the packfile begins immediately after the section header
984 The data transfer of the packfile is always multiplexed, using the same semantics of the
985 \fIside\-band\-64k\fR
986 capability from protocol version 1\&. This means that each packet, during the packfile data stream, is made up of a leading 4\-byte pkt\-line length (typical of the pkt\-line format), followed by a 1\-byte stream code, followed by the actual data\&.
992 The stream code can be one of:
994 2 \- progress messages
995 3 \- fatal error message just before stream aborts
1001 .SS "server\-option"
1003 If advertised, indicates that any number of server specific options can be included in a request\&. This is done by sending each option as a "server\-option=<option>" capability line in the capability\-list section of a request\&.
1005 The provided options must not contain a NUL or LF character\&.
1006 .SS "object\-format"
1008 The server can advertise the \fBobject\-format\fR capability with a value \fBX\fR (in the form \fBobject\-format=X\fR) to notify the client that the server is able to deal with objects using hash algorithm X\&. If not specified, the server is assumed to only handle SHA\-1\&. If the client would like to use a hash algorithm other than SHA\-1, it should specify its object\-format string\&.
1009 .SS "session\-id=<session\-id>"
1011 The server may advertise a session ID that can be used to identify this process across multiple requests\&. The client may advertise its own session ID back to the server as well\&.
1013 Session IDs should be unique to a given process\&. They must fit within a packet\-line, and must not contain non\-printable or whitespace characters\&. The current implementation uses trace2 session IDs (see \m[blue]\fBapi\-trace2\fR\m[]\&\s-2\u[1]\d\s+2 for details), but this may change and users of the session ID should not rely on this fact\&.
1016 \fBobject\-info\fR is the command to retrieve information about one or more objects\&. Its main purpose is to allow a client to make decisions based on this information without having to fully fetch objects\&. Object size is the only information that is currently supported\&.
1018 An \fBobject\-info\fR request takes the following arguments:
1025 Requests size information to be returned for each listed object id\&.
1036 Indicates to the server an object which the client wants to obtain
1043 The response of \fBobject\-info\fR is a list of the requested object ids and associated requested information, each separated by a single space\&.
1049 output = info flush\-pkt
1059 info = PKT\-LINE(attrs) LF)
1060 *PKT\-LINE(obj\-info LF)
1070 attrs = attr | attrs SP attrs
1090 obj\-info = obj\-id SP obj\-size
1097 If the \fIbundle\-uri\fR capability is advertised, the server supports the \(oqbundle\-uri\(cq command\&.
1099 The capability is currently advertised with no value (i\&.e\&. not "bundle\-uri=somevalue"), a value may be added in the future for supporting command\-wide extensions\&. Clients MUST ignore any unknown capability values and proceed with the \*(Aqbundle\-uri` dialog they support\&.
1101 The \fIbundle\-uri\fR command is intended to be issued before \fBfetch\fR to get URIs to bundle files (see \fBgit-bundle\fR(1)) to "seed" and inform the subsequent \fBfetch\fR command\&.
1103 The client CAN issue \fBbundle\-uri\fR before or after any other valid command\&. To be useful to clients it\(cqs expected that it\(cqll be issued after an \fBls\-refs\fR and before \fBfetch\fR, but CAN be issued at any time in the dialog\&.
1106 .nr an-no-space-flag 1
1110 \fBDISCUSSION of bundle-uri\fR
1113 The intent of the feature is optimize for server resource consumption in the common case by changing the common case of fetching a very large PACK during \fBgit-clone\fR(1) into a smaller incremental fetch\&.
1115 It also allows servers to achieve better caching in combination with an \fBuploadpack\&.packObjectsHook\fR (see \fBgit-config\fR(1))\&.
1117 By having new clones or fetches be a more predictable and common negotiation against the tips of recently produces *\&.bundle file(s)\&. Servers might even pre\-generate the results of such negotiations for the \fBuploadpack\&.packObjectsHook\fR as new pushes come in\&.
1119 One way that servers could take advantage of these bundles is that the server would anticipate that fresh clones will download a known bundle, followed by catching up to the current state of the repository using ref tips found in that bundle (or bundles)\&.
1123 .nr an-no-space-flag 1
1127 \fBPROTOCOL for bundle-uri\fR
1130 A \fBbundle\-uri\fR request takes no arguments, and as noted above does not currently advertise a capability value\&. Both may be added in the future\&.
1132 When the client issues a \fBcommand=bundle\-uri\fR request, the response is a list of key\-value pairs provided as packet lines with value \fB<key>=<value>\fR\&. Each \fB<key>\fR should be interpreted as a config key from the \fBbundle\&.*\fR namespace to construct a list of bundles\&. These keys are grouped by a \fBbundle\&.<id>\&.\fR subsection, where each key corresponding to a given \fB<id>\fR contributes attributes to the bundle defined by that \fB<id>\fR\&. See \fBgit-config\fR(1) for the specific details of these keys and how the Git client will interpret their values\&.
1134 Clients MUST parse the line according to the above format, lines that do not conform to the format SHOULD be discarded\&. The user MAY be warned in such a case\&.
1138 .nr an-no-space-flag 1
1142 \fBbundle-uri CLIENT AND SERVER EXPECTATIONS\fR
1147 The content at the advertised URIs MUST be one of two types\&.
1149 The advertised URI may contain a bundle file that
1150 \fBgit bundle verify\fR
1151 would accept\&. I\&.e\&. they MUST contain one or more reference tips for use by the client, MUST indicate prerequisites (in any) with standard "\-" prefixes, and MUST indicate their "object\-format", if applicable\&.
1153 The advertised URI may alternatively contain a plaintext file that
1154 \fBgit config \-\-list\fR
1155 would accept (with the
1157 option)\&. The key\-value pairs in this list are in the
1160 \fBgit-config\fR(1))\&.
1163 bundle\-uri CLIENT ERROR RECOVERY
1165 A client MUST above all gracefully degrade on errors, whether that error is because of bad missing/data in the bundle URI(s), because that client is too dumb to e\&.g\&. understand and fully parse out bundle headers and their prerequisite relationships, or something else\&.
1167 Server operators should feel confident in turning on "bundle\-uri" and not worry if e\&.g\&. their CDN goes down that clones or fetches will run into hard failures\&. Even if the server bundle(s) are incomplete, or bad in some way the client should still end up with a functioning repository, just as if it had chosen not to use this protocol extension\&.
1169 All subsequent discussion on client and server interaction MUST keep this in mind\&.
1172 bundle\-uri SERVER TO CLIENT
1174 The ordering of the returned bundle uris is not significant\&. Clients MUST parse their headers to discover their contained OIDS and prerequisites\&. A client MUST consider the content of the bundle(s) themselves and their header as the ultimate source of truth\&.
1176 A server MAY even return bundle(s) that don\(cqt have any direct relationship to the repository being cloned (either through accident, or intentional "clever" configuration), and expect a client to sort out what data they\(cqd like from the bundle(s), if any\&.
1179 bundle\-uri CLIENT TO SERVER
1181 The client SHOULD provide reference tips found in the bundle header(s) as
1183 lines in any subsequent
1185 request\&. A client MAY also ignore the bundle(s) entirely if doing so is deemed worse for some reason, e\&.g\&. if the bundles can\(cqt be downloaded, it doesn\(cqt like the tips it finds etc\&.
1188 WHEN ADVERTISED BUNDLE(S) REQUIRE NO FURTHER NEGOTIATION
1193 \fBls\-refs\fR, and getting the header(s) of the bundle(s) the client finds that the ref tips it wants can be retrieved entirely from advertised bundle(s), the client MAY disconnect from the Git server\&. The results of such a
1197 should be indistinguishable from the state attained without using bundle\-uri\&.
1200 EARLY CLIENT DISCONNECTIONS AND ERROR RECOVERY
1202 A client MAY perform an early disconnect while still downloading the bundle(s) (having streamed and parsed their headers)\&. In such a case the client MUST gracefully recover from any errors related to finishing the download and validation of the bundle(s)\&.
1204 I\&.e\&. a client might need to re\-connect and issue a
1206 command, and possibly fall back to not making use of
1210 This "MAY" behavior is specified as such (and not a "SHOULD") on the assumption that a server advertising bundle uris is more likely than not to be serving up a relatively large repository, and to be pointing to URIs that have a good chance of being in working order\&. A client MAY e\&.g\&. look at the payload size of the bundles as a heuristic to see if an early disconnect is worth it, should falling back on a full "fetch" dialog be necessary\&.
1213 WHEN ADVERTISED BUNDLE(S) REQUIRE FURTHER NEGOTIATION
1215 A client SHOULD commence a negotiation of a PACK from the server via the "fetch" command using the OID tips found in advertised bundles, even if\(cqs still in the process of downloading those bundle(s)\&.
1217 This allows for aggressive early disconnects from any interactive server dialog\&. The client blindly trusts that the advertised OID tips are relevant, and issues them as
1219 lines, it then requests any tips it would like (usually from the "ls\-refs" advertisement) via
1221 lines\&. The server will then compute a (hopefully small) PACK with the expected difference between the tips from the bundle(s) and the data requested\&.
1223 The only connection the client then needs to keep active is to the concurrently downloading static bundle(s), when those and the incremental PACK are retrieved they should be inflated and validated\&. Any errors at this point should be gracefully recovered from, see above\&.
1228 .nr an-no-space-flag 1
1232 \fBbundle-uri PROTOCOL FEATURES\fR
1235 The client constructs a bundle list from the \fB<key>=<value>\fR pairs provided by the server\&. These pairs are part of the \fBbundle\&.*\fR namespace as documented in \fBgit-config\fR(1)\&. In this section, we discuss some of these keys and describe the actions the client will do in response to this information\&.
1237 In particular, the \fBbundle\&.version\fR key specifies an integer value\&. The only accepted value at the moment is \fB1\fR, but if the client sees an unexpected value here then the client MUST ignore the bundle list\&.
1239 As long as \fBbundle\&.version\fR is understood, all other unknown keys MAY be ignored by the client\&. The server will guarantee compatibility with older clients, though newer clients may be better able to use the extra keys to minimize downloads\&.
1241 Any backwards\-incompatible addition of pre\-URI key\-value will be guarded by a new \fBbundle\&.version\fR value or values in \fIbundle\-uri\fR capability advertisement itself, and/or by new future \fBbundle\-uri\fR request arguments\&.
1243 Some example key\-value pairs that are not currently implemented but could be implemented in the future include:
1247 \h'-04'\(bu\h'+03'\c
1253 Add a "hash=<val>" or "size=<bytes>" advertise the expected hash or size of the bundle file\&.
1258 \h'-04'\(bu\h'+03'\c
1264 Advertise that one or more bundle files are the same (to e\&.g\&. have clients round\-robin or otherwise choose one of N possible files)\&.
1269 \h'-04'\(bu\h'+03'\c
1275 A "oid=<OID>" shortcut and "prerequisite=<OID>" shortcut\&. For expressing the common case of a bundle with one tip and no prerequisites, or one tip and one prerequisite\&.
1277 This would allow for optimizing the common case of servers who\(cqd like to provide one "big bundle" containing only their "main" branch, and/or incremental updates thereof\&.
1279 A client receiving such a a response MAY assume that they can skip retrieving the header from a bundle at the indicated URI, and thus save themselves and the server(s) the request(s) needed to inspect the headers of that bundle or bundles\&.
1284 Part of the \fBgit\fR(1) suite
1289 \%git-htmldocs/technical/api-trace2.html