1Git Protocol Capabilities 2========================= 3 4Servers SHOULD support all capabilities defined in this document. 5 6On the very first line of the initial server response of either 7receive-pack and upload-pack the first reference is followed by 8a NUL byte and then a list of space delimited server capabilities. 9These allow the server to declare what it can and cannot support 10to the client. 11 12Client will then send a space separated list of capabilities it wants 13to be in effect. The client MUST NOT ask for capabilities the server 14did not say it supports. 15 16Server MUST diagnose and abort if capabilities it does not understand 17was sent. Server MUST NOT ignore capabilities that client requested 18and server advertised. As a consequence of these rules, server MUST 19NOT advertise capabilities it does not understand. 20 21The 'atomic', 'report-status', 'delete-refs', 'quiet', and 'push-cert' 22capabilities are sent and recognized by the receive-pack (push to server) 23process. 24 25The 'ofs-delta' and 'side-band-64k' capabilities are sent and recognized 26by both upload-pack and receive-pack protocols. The 'agent' capability 27may optionally be sent in both protocols. 28 29All other capabilities are only recognized by the upload-pack (fetch 30from server) process. 31 32multi_ack 33--------- 34 35The 'multi_ack' capability allows the server to return "ACK obj-id 36continue" as soon as it finds a commit that it can use as a common 37base, between the client's wants and the client's have set. 38 39By sending this early, the server can potentially head off the client 40from walking any further down that particular branch of the client's 41repository history. The client may still need to walk down other 42branches, sending have lines for those, until the server has a 43complete cut across the DAG, or the client has said "done". 44 45Without multi_ack, a client sends have lines in --date-order until 46the server has found a common base. That means the client will send 47have lines that are already known by the server to be common, because 48they overlap in time with another branch that the server hasn't found 49a common base on yet. 50 51For example suppose the client has commits in caps that the server 52doesn't and the server has commits in lower case that the client 53doesn't, as in the following diagram: 54 55 +---- u ---------------------- x 56 / +----- y 57 / / 58 a -- b -- c -- d -- E -- F 59 \ 60 +--- Q -- R -- S 61 62If the client wants x,y and starts out by saying have F,S, the server 63doesn't know what F,S is. Eventually the client says "have d" and 64the server sends "ACK d continue" to let the client know to stop 65walking down that line (so don't send c-b-a), but it's not done yet, 66it needs a base for x. The client keeps going with S-R-Q, until a 67gets reached, at which point the server has a clear base and it all 68ends. 69 70Without multi_ack the client would have sent that c-b-a chain anyway, 71interleaved with S-R-Q. 72 73multi_ack_detailed 74------------------ 75This is an extension of multi_ack that permits client to better 76understand the server's in-memory state. See pack-protocol.txt, 77section "Packfile Negotiation" for more information. 78 79no-done 80------- 81This capability should only be used with the smart HTTP protocol. If 82multi_ack_detailed and no-done are both present, then the sender is 83free to immediately send a pack following its first "ACK obj-id ready" 84message. 85 86Without no-done in the smart HTTP protocol, the server session would 87end and the client has to make another trip to send "done" before 88the server can send the pack. no-done removes the last round and 89thus slightly reduces latency. 90 91thin-pack 92--------- 93 94A thin pack is one with deltas which reference base objects not 95contained within the pack (but are known to exist at the receiving 96end). This can reduce the network traffic significantly, but it 97requires the receiving end to know how to "thicken" these packs by 98adding the missing bases to the pack. 99 100The upload-pack server advertises 'thin-pack' when it can generate 101and send a thin pack. A client requests the 'thin-pack' capability 102when it understands how to "thicken" it, notifying the server that 103it can receive such a pack. A client MUST NOT request the 104'thin-pack' capability if it cannot turn a thin pack into a 105self-contained pack. 106 107Receive-pack, on the other hand, is assumed by default to be able to 108handle thin packs, but can ask the client not to use the feature by 109advertising the 'no-thin' capability. A client MUST NOT send a thin 110pack if the server advertises the 'no-thin' capability. 111 112The reasons for this asymmetry are historical. The receive-pack 113program did not exist until after the invention of thin packs, so 114historically the reference implementation of receive-pack always 115understood thin packs. Adding 'no-thin' later allowed receive-pack 116to disable the feature in a backwards-compatible manner. 117 118 119side-band, side-band-64k 120------------------------ 121 122This capability means that server can send, and client understand multiplexed 123progress reports and error info interleaved with the packfile itself. 124 125These two options are mutually exclusive. A modern client always 126favors 'side-band-64k'. 127 128Either mode indicates that the packfile data will be streamed broken 129up into packets of up to either 1000 bytes in the case of 'side_band', 130or 65520 bytes in the case of 'side_band_64k'. Each packet is made up 131of a leading 4-byte pkt-line length of how much data is in the packet, 132followed by a 1-byte stream code, followed by the actual data. 133 134The stream code can be one of: 135 136 1 - pack data 137 2 - progress messages 138 3 - fatal error message just before stream aborts 139 140The "side-band-64k" capability came about as a way for newer clients 141that can handle much larger packets to request packets that are 142actually crammed nearly full, while maintaining backward compatibility 143for the older clients. 144 145Further, with side-band and its up to 1000-byte messages, it's actually 146999 bytes of payload and 1 byte for the stream code. With side-band-64k, 147same deal, you have up to 65519 bytes of data and 1 byte for the stream 148code. 149 150The client MUST send only maximum of one of "side-band" and "side- 151band-64k". Server MUST diagnose it as an error if client requests 152both. 153 154ofs-delta 155--------- 156 157Server can send, and client understand PACKv2 with delta referring to 158its base by position in pack rather than by an obj-id. That is, they can 159send/read OBJ_OFS_DELTA (aka type 6) in a packfile. 160 161agent 162----- 163 164The server may optionally send a capability of the form `agent=X` to 165notify the client that the server is running version `X`. The client may 166optionally return its own agent string by responding with an `agent=Y` 167capability (but it MUST NOT do so if the server did not mention the 168agent capability). The `X` and `Y` strings may contain any printable 169ASCII characters except space (i.e., the byte range 32 < x < 127), and 170are typically of the form "package/version" (e.g., "git/1.8.3.1"). The 171agent strings are purely informative for statistics and debugging 172purposes, and MUST NOT be used to programmatically assume the presence 173or absence of particular features. 174 175shallow 176------- 177 178This capability adds "deepen", "shallow" and "unshallow" commands to 179the fetch-pack/upload-pack protocol so clients can request shallow 180clones. 181 182no-progress 183----------- 184 185The client was started with "git clone -q" or something, and doesn't 186want that side band 2. Basically the client just says "I do not 187wish to receive stream 2 on sideband, so do not send it to me, and if 188you did, I will drop it on the floor anyway". However, the sideband 189channel 3 is still used for error responses. 190 191include-tag 192----------- 193 194The 'include-tag' capability is about sending annotated tags if we are 195sending objects they point to. If we pack an object to the client, and 196a tag object points exactly at that object, we pack the tag object too. 197In general this allows a client to get all new annotated tags when it 198fetches a branch, in a single network connection. 199 200Clients MAY always send include-tag, hardcoding it into a request when 201the server advertises this capability. The decision for a client to 202request include-tag only has to do with the client's desires for tag 203data, whether or not a server had advertised objects in the 204refs/tags/* namespace. 205 206Servers MUST pack the tags if their referrant is packed and the client 207has requested include-tags. 208 209Clients MUST be prepared for the case where a server has ignored 210include-tag and has not actually sent tags in the pack. In such 211cases the client SHOULD issue a subsequent fetch to acquire the tags 212that include-tag would have otherwise given the client. 213 214The server SHOULD send include-tag, if it supports it, regardless 215of whether or not there are tags available. 216 217report-status 218------------- 219 220The receive-pack process can receive a 'report-status' capability, 221which tells it that the client wants a report of what happened after 222a packfile upload and reference update. If the pushing client requests 223this capability, after unpacking and updating references the server 224will respond with whether the packfile unpacked successfully and if 225each reference was updated successfully. If any of those were not 226successful, it will send back an error message. See pack-protocol.txt 227for example messages. 228 229delete-refs 230----------- 231 232If the server sends back the 'delete-refs' capability, it means that 233it is capable of accepting a zero-id value as the target 234value of a reference update. It is not sent back by the client, it 235simply informs the client that it can be sent zero-id values 236to delete references. 237 238quiet 239----- 240 241If the receive-pack server advertises the 'quiet' capability, it is 242capable of silencing human-readable progress output which otherwise may 243be shown when processing the received pack. A send-pack client should 244respond with the 'quiet' capability to suppress server-side progress 245reporting if the local progress reporting is also being suppressed 246(e.g., via `push -q`, or if stderr does not go to a tty). 247 248atomic 249------ 250 251If the server sends the 'atomic' capability it is capable of accepting 252atomic pushes. If the pushing client requests this capability, the server 253will update the refs in one atomic transaction. Either all refs are 254updated or none. 255 256push-options 257------------ 258 259If the server sends the 'push-options' capability it is able to accept 260push options after the update commands have been sent, but before the 261packfile is streamed. If the pushing client requests this capability, 262the server will pass the options to the pre- and post- receive hooks 263that process this push request. 264 265allow-tip-sha1-in-want 266---------------------- 267 268If the upload-pack server advertises this capability, fetch-pack may 269send "want" lines with SHA-1s that exist at the server but are not 270advertised by upload-pack. 271 272allow-reachable-sha1-in-want 273---------------------------- 274 275If the upload-pack server advertises this capability, fetch-pack may 276send "want" lines with SHA-1s that exist at the server but are not 277advertised by upload-pack. 278 279push-cert=<nonce> 280----------------- 281 282The receive-pack server that advertises this capability is willing 283to accept a signed push certificate, and asks the <nonce> to be 284included in the push certificate. A send-pack client MUST NOT 285send a push-cert packet unless the receive-pack server advertises 286this capability.