In general, you're going to want to use a Git library for this unless you're planning to write your own. Here's why:
Git supports two types of HTTP remotes: the DAV-based (dumb) protocol and the smart protocol. In addition, the smart protocol also supports protocols 0 and 1 (which are nearly identical) and protocol 2, which is quite different. So to implement this in a meaningful way, you're going to have to implement a lot of functionality.
In addition, the smart protocol performs negotiation of what data is present on both sides and sends only the data that differs. In such a case, you necessarily have to walk the history of the repository to determine what objects are common, which means you will also need to read loose and packed objects, read and write references, and fill out the missing objects in thin packs. All of these require basic Git primitives.
If you still want to do it nevertheless, you should look in the Documentation/technical
directory in the Git source code at the http-protocol.txt
and pack-protocol.txt
files, plus the files starting with protocol-
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…