forked from jelmer/dulwich
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protocol.txt
65 lines (47 loc) · 2.22 KB
/
protocol.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.. _protocol:
===================
Git Server Protocol
===================
Transport
=========
The Git protocol operates over pipes or TCP/IP. When a client connects over
TCP/IP, it sends a header that tells the server which program to run and what
parameters to use. When invoked over SSH, git will run a program with the
parameters as command line arguments.
Protocols
=========
Basics
------
Git communicates with a server by piping data between a local program and a
remote program.
A common way of sending a unit of information is a pkt_line. This is a 4 byte
size as human encoded hex (i.e. totally underusing the 4 bytes...) that tells
you the size of the payload, followed by the payload. The size includes the 4
byes used by the size itself.
0009ABCD\n
Git can also multiplex data using the sideband. As well as 4 bytes size, there
would be a 1 byte channel number. This is in binary, so ``1`` will be ``\x01``.
Typically Git will piggyback a list of capabilities on the first pkt_line it
sends. It will also look for capabilities in the first pkt_like it receives.
Git will degrade as much as possible when encountering a server or client with
differing capabilities.
git-upload-pack
---------------
git-upload pack is used by git-ls-remote, git-clone, git-fetch and git-pull.
And i'm sure others. Typically a client will connect a local git-fetch-pack to
a remote git-upload-pack.
Capabilities for this protocol include multi_ack, thin-pack, ofs-delta,
sideband and sideband-64k A thin pack can reference objects not in the current
pack.
The server tells the client what refs it has. The client states which of those
SHA1's it would like. It then starts to report which SHA1's it has. The server
ACKs these allowing the client to work out when to stop sending SHA1's. This
saves a lot of transfer because the client can make decisions like "well if it
has this SHA, then it has all its parents so i dont need to care about those".
When the client stops sending shas, the server can work out an optimal pack and
then send it to the client.
git-receive-pack
----------------
git-receive-pack is used by git push. Typically a client connects a local
git-send-pack to a remote git-receive-pack.
Capabilities include report-status and delete-ref.