Skip to contentSkip to conversation

git protocol specification

DISCUSSION Tom Werner 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Tom Werner

author
#0 lore raw

I'm working on a flexible Erlang replacement for git-daemon and would like to know if there is a specification available for the protocol that git-upload-pack and git-receive-pack use. I've reverse engineered it but have come across some points that seem inconsistent. Before I dig into the C code in earnest I wanted to see if there's anything like spec document for the system. Thanks!

Signature · 2 lines
Tom Preston-Werner
github.com/mojombo

begin:vcard
fn:Tom Preston-Werner
n:Preston-Werner;Tom
email;internet:[email protected]
tel;cell:760.672.0832
x-mozilla-html:FALSE
version:2.1
end:vcard

#1 lore raw
Quoted 6 lines · Tom Werner

I'm working on a flexible Erlang replacement for git-daemon and would like to know if there is a specification available for the protocol that git-upload-pack and git-receive-pack use. I've reverse engineered it but have come across some points that seem inconsistent. Before I dig into the C code in earnest I wanted to see if there's anything like spec document for the system. Thanks!

I'm curious, are you planning on implementing git-upload-pack and git-receive-pack in Erlang as well? Or are you just doing the git-daemon frontend and spawn the C git binaries as port processes?

git-receive-pack isn't too much trouble, the protocol on the server side without the tell-me-more is fairly simple to implement, once you have something like index-pack or unpack-objects implemented. But that is somewhat non-trivial to do.

git-upload-pack is much more complex on the server side as you must actually create the packfile, which means you also need to compute the set of objects the client is missing, as well as tell the client when you have enough "have" lines in order to compute the smallest reasonable pack possible for the data transfer.

I know Erlang is really good at protocol handling and binary formatting/parsing, but I don't know if you have a good git object navigation library available to you in Erlang. Its been years since I last worked with it, or was involved in its community... ;-)

Signature · 1 line
Shawn.
#2 lore raw
In reply to Tom Werner

Hi,

Quoted 3 lines · Tom Werner

I'm working on a flexible Erlang replacement for git-daemon and would like to know if there is a specification available for the protocol that git-upload-pack and git-receive-pack use.

How about Documentation/technical/pack-protocol.txt?

Ciao,
Dscho

#3 lore raw
Quoted 7 lines · Johannes Schindelin
Quoted 3 lines · Tom Werner

I'm working on a flexible Erlang replacement for git-daemon and would like to know if there is a specification available for the protocol that git-upload-pack and git-receive-pack use.

How about Documentation/technical/pack-protocol.txt?

You may also want to look at jgit's source code. Its a cleaner implementation of the protocol in 100% Java. Not something you would want to try and call directly from in Erlang, but it may be easier to follow.

http://repo.or.cz/w/egit.git/

Look inside of the org.spearce.jgit/src/org/spearce/jgit/transport package. In particular the client side of the protocol for git://
is in the TransportGitAnon class as two inner subclasses, one for fetch ('git-upload-pack') and another for push ('git-receive-pack').

Signature · 1 line
Shawn.