threads / discuss / 14376

git protocol specification

Subject: git protocol specification

## tl;dr

4 messages between Jul 9, 2008 and Jul 10, 2008.

replies: 3people: 3as markdown or json

Tom Werner· Jul 9, 2008, 18:23 UTC · lore

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!

-- 
Tom Preston-Werner
github.com/mojombo



begin:vcard
fn:Tom Preston-Werner
n:Preston-Werner;Tom
email;internet:tom@mojombo.com
tel;cell:760.672.0832
x-mozilla-html:FALSE
version:2.1
end:vcard
Johannes Schindelin· Jul 9, 2008, 18:45 UTC · re: Tom Werner · lore

Re: git protocol specification

Hi,
On Wed, 9 Jul 2008, Tom Werner wrote:
> 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

Shawn O. Pearce· Jul 10, 2008, 01:47 UTC · re: Johannes Schindelin · lore

Re: git protocol specification

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 7 quoted lines
> On Wed, 9 Jul 2008, Tom Werner wrote:
> 
> > 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').

-- 
Shawn.
Shawn O. Pearce· Jul 10, 2008, 02:32 UTC · re: Tom Werner · lore

Re: git protocol specification

Tom Werner <pubsub@rubyisawesome.com> wrote:
Show 6 quoted lines
> 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... ;-)

-- 
Shawn.

← back to recent threads