Skip to content

Commit 3e8cd96

Browse files
committed
Merge branch 'an/shallow-doc' into maint
* an/shallow-doc: Document the underlying protocol used by shallow repositories and --depth commands. Fix documentation of fetch-pack that implies that the client can disconnect after sending wants.
2 parents 055f2c5 + 4a1c269 commit 3e8cd96

File tree

1 file changed

+74
-29
lines changed

1 file changed

+74
-29
lines changed

Documentation/technical/pack-protocol.txt

Lines changed: 74 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -179,34 +179,36 @@ and descriptions.
179179

180180
Packfile Negotiation
181181
--------------------
182-
After reference and capabilities discovery, the client can decide
183-
to terminate the connection by sending a flush-pkt, telling the
184-
server it can now gracefully terminate (as happens with the ls-remote
185-
command) or it can enter the negotiation phase, where the client and
186-
server determine what the minimal packfile necessary for transport is.
187-
188-
Once the client has the initial list of references that the server
189-
has, as well as the list of capabilities, it will begin telling the
190-
server what objects it wants and what objects it has, so the server
191-
can make a packfile that only contains the objects that the client needs.
192-
The client will also send a list of the capabilities it wants to be in
193-
effect, out of what the server said it could do with the first 'want' line.
182+
After reference and capabilities discovery, the client can decide to
183+
terminate the connection by sending a flush-pkt, telling the server it can
184+
now gracefully terminate, and disconnect, when it does not need any pack
185+
data. This can happen with the ls-remote command, and also can happen when
186+
the client already is up-to-date.
187+
188+
Otherwise, it enters the negotiation phase, where the client and
189+
server determine what the minimal packfile necessary for transport is,
190+
by telling the server what objects it wants, its shallow objects
191+
(if any), and the maximum commit depth it wants (if any). The client
192+
will also send a list of the capabilities it wants to be in effect,
193+
out of what the server said it could do with the first 'want' line.
194194

195195
----
196196
upload-request = want-list
197-
have-list
198-
compute-end
197+
*shallow-line
198+
*1depth-request
199+
flush-pkt
199200

200201
want-list = first-want
201202
*additional-want
202-
flush-pkt
203+
204+
shallow-line = PKT_LINE("shallow" SP obj-id)
205+
206+
depth-request = PKT_LINE("deepen" SP depth)
203207

204208
first-want = PKT-LINE("want" SP obj-id SP capability-list LF)
205209
additional-want = PKT-LINE("want" SP obj-id LF)
206210

207-
have-list = *have-line
208-
have-line = PKT-LINE("have" SP obj-id LF)
209-
compute-end = flush-pkt / PKT-LINE("done")
211+
depth = 1*DIGIT
210212
----
211213

212214
Clients MUST send all the obj-ids it wants from the reference
@@ -215,21 +217,64 @@ discovery phase as 'want' lines. Clients MUST send at least one
215217
obj-id in a 'want' command which did not appear in the response
216218
obtained through ref discovery.
217219

218-
If client is requesting a shallow clone, it will now send a 'deepen'
219-
line with the depth it is requesting.
220+
The client MUST write all obj-ids which it only has shallow copies
221+
of (meaning that it does not have the parents of a commit) as
222+
'shallow' lines so that the server is aware of the limitations of
223+
the client's history. Clients MUST NOT mention an obj-id which
224+
it does not know exists on the server.
225+
226+
The client now sends the maximum commit history depth it wants for
227+
this transaction, which is the number of commits it wants from the
228+
tip of the history, if any, as a 'deepen' line. A depth of 0 is the
229+
same as not making a depth request. The client does not want to receive
230+
any commits beyond this depth, nor objects needed only to complete
231+
those commits. Commits whose parents are not received as a result are
232+
defined as shallow and marked as such in the server. This information
233+
is sent back to the client in the next step.
234+
235+
Once all the 'want's and 'shallow's (and optional 'deepen') are
236+
transferred, clients MUST send a flush-pkt, to tell the server side
237+
that it is done sending the list.
238+
239+
Otherwise, if the client sent a positive depth request, the server
240+
will determine which commits will and will not be shallow and
241+
send this information to the client. If the client did not request
242+
a positive depth, this step is skipped.
220243

221-
Once all the "want"s (and optional 'deepen') are transferred,
222-
clients MUST send a flush-pkt. If the client has all the references
223-
on the server, client flushes and disconnects.
244+
----
245+
shallow-update = *shallow-line
246+
*unshallow-line
247+
flush-pkt
224248

225-
TODO: shallow/unshallow response and document the deepen command in the ABNF.
249+
shallow-line = PKT-LINE("shallow" SP obj-id)
250+
251+
unshallow-line = PKT-LINE("unshallow" SP obj-id)
252+
----
253+
254+
If the client has requested a positive depth, the server will compute
255+
the set of commits which are no deeper than the desired depth, starting
256+
at the client's wants. The server writes 'shallow' lines for each
257+
commit whose parents will not be sent as a result. The server writes
258+
an 'unshallow' line for each commit which the client has indicated is
259+
shallow, but is no longer shallow at the currently requested depth
260+
(that is, its parents will now be sent). The server MUST NOT mark
261+
as unshallow anything which the client has not indicated was shallow.
226262

227263
Now the client will send a list of the obj-ids it has using 'have'
228-
lines. In multi_ack mode, the canonical implementation will send up
229-
to 32 of these at a time, then will send a flush-pkt. The canonical
230-
implementation will skip ahead and send the next 32 immediately,
231-
so that there is always a block of 32 "in-flight on the wire" at a
232-
time.
264+
lines, so the server can make a packfile that only contains the objects
265+
that the client needs. In multi_ack mode, the canonical implementation
266+
will send up to 32 of these at a time, then will send a flush-pkt. The
267+
canonical implementation will skip ahead and send the next 32 immediately,
268+
so that there is always a block of 32 "in-flight on the wire" at a time.
269+
270+
----
271+
upload-haves = have-list
272+
compute-end
273+
274+
have-list = *have-line
275+
have-line = PKT-LINE("have" SP obj-id LF)
276+
compute-end = flush-pkt / PKT-LINE("done")
277+
----
233278

234279
If the server reads 'have' lines, it then will respond by ACKing any
235280
of the obj-ids the client said it had that the server also has. The

0 commit comments

Comments
 (0)