Documentation / technical / protocol-capabilities.txton commit Merge branch 'bw/cp-a-is-gnuism' (b7804cf)
   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 'report-status' and 'delete-refs' capabilities are sent and
  22recognized by the receive-pack (push to server) process.
  23
  24The 'ofs-delta' capability is sent and recognized by both upload-pack
  25and receive-pack protocols.
  26
  27All other capabilities are only recognized by the upload-pack (fetch
  28from server) process.
  29
  30multi_ack
  31---------
  32
  33The 'multi_ack' capability allows the server to return "ACK obj-id
  34continue" as soon as it finds a commit that it can use as a common
  35base, between the client's wants and the client's have set.
  36
  37By sending this early, the server can potentially head off the client
  38from walking any further down that particular branch of the client's
  39repository history.  The client may still need to walk down other
  40branches, sending have lines for those, until the server has a
  41complete cut across the DAG, or the client has said "done".
  42
  43Without multi_ack, a client sends have lines in --date-order until
  44the server has found a common base.  That means the client will send
  45have lines that are already known by the server to be common, because
  46they overlap in time with another branch that the server hasn't found
  47a common base on yet.
  48
  49For example suppose the client has commits in caps that the server
  50doesn't and the server has commits in lower case that the client
  51doesn't, as in the following diagram:
  52
  53       +---- u ---------------------- x
  54      /              +----- y
  55     /              /
  56    a -- b -- c -- d -- E -- F
  57       \
  58        +--- Q -- R -- S
  59
  60If the client wants x,y and starts out by saying have F,S, the server
  61doesn't know what F,S is.  Eventually the client says "have d" and
  62the server sends "ACK d continue" to let the client know to stop
  63walking down that line (so don't send c-b-a), but it's not done yet,
  64it needs a base for x. The client keeps going with S-R-Q, until a
  65gets reached, at which point the server has a clear base and it all
  66ends.
  67
  68Without multi_ack the client would have sent that c-b-a chain anyway,
  69interleaved with S-R-Q.
  70
  71thin-pack
  72---------
  73
  74This capability means that the server can send a 'thin' pack, a pack
  75which does not contain base objects; if those base objects are available
  76on client side. Client requests 'thin-pack' capability when it
  77understands how to "thicken" it by adding required delta bases making
  78it self-contained.
  79
  80Client MUST NOT request 'thin-pack' capability if it cannot turn a thin
  81pack into a self-contained pack.
  82
  83
  84side-band, side-band-64k
  85------------------------
  86
  87This capability means that server can send, and client understand multiplexed
  88progress reports and error info interleaved with the packfile itself.
  89
  90These two options are mutually exclusive. A modern client always
  91favors 'side-band-64k'.
  92
  93Either mode indicates that the packfile data will be streamed broken
  94up into packets of up to either 1000 bytes in the case of 'side_band',
  95or 65520 bytes in the case of 'side_band_64k'. Each packet is made up
  96of a leading 4-byte pkt-line length of how much data is in the packet,
  97followed by a 1-byte stream code, followed by the actual data.
  98
  99The stream code can be one of:
 100
 101 1 - pack data
 102 2 - progress messages
 103 3 - fatal error message just before stream aborts
 104
 105The "side-band-64k" capability came about as a way for newer clients
 106that can handle much larger packets to request packets that are
 107actually crammed nearly full, while maintaining backward compatibility
 108for the older clients.
 109
 110Further, with side-band and its up to 1000-byte messages, it's actually
 111999 bytes of payload and 1 byte for the stream code. With side-band-64k,
 112same deal, you have up to 65519 bytes of data and 1 byte for the stream
 113code.
 114
 115The client MUST send only maximum of one of "side-band" and "side-
 116band-64k".  Server MUST diagnose it as an error if client requests
 117both.
 118
 119ofs-delta
 120---------
 121
 122Server can send, and client understand PACKv2 with delta referring to
 123its base by position in pack rather than by an obj-id.  That is, they can
 124send/read OBJ_OFS_DELTA (aka type 6) in a packfile.
 125
 126shallow
 127-------
 128
 129This capability adds "deepen", "shallow" and "unshallow" commands to
 130the  fetch-pack/upload-pack protocol so clients can request shallow
 131clones.
 132
 133no-progress
 134-----------
 135
 136The client was started with "git clone -q" or something, and doesn't
 137want that side band 2.  Basically the client just says "I do not
 138wish to receive stream 2 on sideband, so do not send it to me, and if
 139you did, I will drop it on the floor anyway".  However, the sideband
 140channel 3 is still used for error responses.
 141
 142include-tag
 143-----------
 144
 145The 'include-tag' capability is about sending annotated tags if we are
 146sending objects they point to.  If we pack an object to the client, and
 147a tag object points exactly at that object, we pack the tag object too.
 148In general this allows a client to get all new annotated tags when it
 149fetches a branch, in a single network connection.
 150
 151Clients MAY always send include-tag, hardcoding it into a request when
 152the server advertises this capability. The decision for a client to
 153request include-tag only has to do with the client's desires for tag
 154data, whether or not a server had advertised objects in the
 155refs/tags/* namespace.
 156
 157Servers MUST pack the tags if their referrant is packed and the client
 158has requested include-tags.
 159
 160Clients MUST be prepared for the case where a server has ignored
 161include-tag and has not actually sent tags in the pack.  In such
 162cases the client SHOULD issue a subsequent fetch to acquire the tags
 163that include-tag would have otherwise given the client.
 164
 165The server SHOULD send include-tag, if it supports it, regardless
 166of whether or not there are tags available.
 167
 168report-status
 169-------------
 170
 171The upload-pack process can receive a 'report-status' capability,
 172which tells it that the client wants a report of what happened after
 173a packfile upload and reference update.  If the pushing client requests
 174this capability, after unpacking and updating references the server
 175will respond with whether the packfile unpacked successfully and if
 176each reference was updated successfully.  If any of those were not
 177successful, it will send back an error message.  See pack-protocol.txt
 178for example messages.
 179
 180delete-refs
 181-----------
 182
 183If the server sends back the 'delete-refs' capability, it means that
 184it is capable of accepting a zero-id value as the target
 185value of a reference update.  It is not sent back by the client, it
 186simply informs the client that it can be sent zero-id values
 187to delete references.