|
| 1 | +Read Object Process |
| 2 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 3 | + |
| 4 | +The read-object process enables Git to read all missing blobs with a |
| 5 | +single process invocation for the entire life of a single Git command. |
| 6 | +This is achieved by using a packet format (pkt-line, see technical/ |
| 7 | +protocol-common.txt) based protocol over standard input and standard |
| 8 | +output as follows. All packets, except for the "*CONTENT" packets and |
| 9 | +the "0000" flush packet, are considered text and therefore are |
| 10 | +terminated by a LF. |
| 11 | + |
| 12 | +Git starts the process when it encounters the first missing object that |
| 13 | +needs to be retrieved. After the process is started, Git sends a welcome |
| 14 | +message ("git-read-object-client"), a list of supported protocol version |
| 15 | +numbers, and a flush packet. Git expects to read a welcome response |
| 16 | +message ("git-read-object-server"), exactly one protocol version number |
| 17 | +from the previously sent list, and a flush packet. All further |
| 18 | +communication will be based on the selected version. |
| 19 | + |
| 20 | +The remaining protocol description below documents "version=1". Please |
| 21 | +note that "version=42" in the example below does not exist and is only |
| 22 | +there to illustrate how the protocol would look with more than one |
| 23 | +version. |
| 24 | + |
| 25 | +After the version negotiation Git sends a list of all capabilities that |
| 26 | +it supports and a flush packet. Git expects to read a list of desired |
| 27 | +capabilities, which must be a subset of the supported capabilities list, |
| 28 | +and a flush packet as response: |
| 29 | +------------------------ |
| 30 | +packet: git> git-read-object-client |
| 31 | +packet: git> version=1 |
| 32 | +packet: git> version=42 |
| 33 | +packet: git> 0000 |
| 34 | +packet: git< git-read-object-server |
| 35 | +packet: git< version=1 |
| 36 | +packet: git< 0000 |
| 37 | +packet: git> capability=get |
| 38 | +packet: git> capability=have |
| 39 | +packet: git> capability=put |
| 40 | +packet: git> capability=not-yet-invented |
| 41 | +packet: git> 0000 |
| 42 | +packet: git< capability=get |
| 43 | +packet: git< 0000 |
| 44 | +------------------------ |
| 45 | +The only supported capability in version 1 is "get". |
| 46 | + |
| 47 | +Afterwards Git sends a list of "key=value" pairs terminated with a flush |
| 48 | +packet. The list will contain at least the command (based on the |
| 49 | +supported capabilities) and the sha1 of the object to retrieve. Please |
| 50 | +note, that the process must not send any response before it received the |
| 51 | +final flush packet. |
| 52 | + |
| 53 | +When the process receives the "get" command, it should make the requested |
| 54 | +object available in the git object store and then return success. Git will |
| 55 | +then check the object store again and this time find it and proceed. |
| 56 | +------------------------ |
| 57 | +packet: git> command=get |
| 58 | +packet: git> sha1=0a214a649e1b3d5011e14a3dc227753f2bd2be05 |
| 59 | +packet: git> 0000 |
| 60 | +------------------------ |
| 61 | + |
| 62 | +The process is expected to respond with a list of "key=value" pairs |
| 63 | +terminated with a flush packet. If the process does not experience |
| 64 | +problems then the list must contain a "success" status. |
| 65 | +------------------------ |
| 66 | +packet: git< status=success |
| 67 | +packet: git< 0000 |
| 68 | +------------------------ |
| 69 | + |
| 70 | +In case the process cannot or does not want to process the content, it |
| 71 | +is expected to respond with an "error" status. |
| 72 | +------------------------ |
| 73 | +packet: git< status=error |
| 74 | +packet: git< 0000 |
| 75 | +------------------------ |
| 76 | + |
| 77 | +In case the process cannot or does not want to process the content as |
| 78 | +well as any future content for the lifetime of the Git process, then it |
| 79 | +is expected to respond with an "abort" status at any point in the |
| 80 | +protocol. |
| 81 | +------------------------ |
| 82 | +packet: git< status=abort |
| 83 | +packet: git< 0000 |
| 84 | +------------------------ |
| 85 | + |
| 86 | +Git neither stops nor restarts the process in case the "error"/"abort" |
| 87 | +status is set. |
| 88 | + |
| 89 | +If the process dies during the communication or does not adhere to the |
| 90 | +protocol then Git will stop the process and restart it with the next |
| 91 | +object that needs to be processed. |
| 92 | + |
| 93 | +After the read-object process has processed an object it is expected to |
| 94 | +wait for the next "key=value" list containing a command. Git will close |
| 95 | +the command pipe on exit. The process is expected to detect EOF and exit |
| 96 | +gracefully on its own. Git will wait until the process has stopped. |
| 97 | + |
| 98 | +A long running read-object process demo implementation can be found in |
| 99 | +`contrib/long-running-read-object/example.pl` located in the Git core |
| 100 | +repository. If you develop your own long running process then the |
| 101 | +`GIT_TRACE_PACKET` environment variables can be very helpful for |
| 102 | +debugging (see linkgit:git[1]). |
0 commit comments