# git protocol specification

4 messages from 2008-07-09 to 2008-07-10. Participants: Tom Werner, Johannes Schindelin, Shawn O. Pearce.
Thread: https://gitlist.dev/t/14376

## Tom Werner, 2008-07-09 18:23

Subject: git protocol specification
Message-ID: <48750231.4020805@rubyisawesome.com>
URL: https://gitlist.dev/e/48750231.4020805%40rubyisawesome.com

```
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, 2008-07-09 18:45

Subject: Re: git protocol specification
Message-ID: <alpine.DEB.1.00.0807092044120.4010@eeepc-johanness>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0807092044120.4010%40eeepc-johanness
In-Reply-To: <48750231.4020805@rubyisawesome.com>

```
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, 2008-07-10 01:47

Subject: Re: git protocol specification
Message-ID: <20080710014750.GA7714@spearce.org>
URL: https://gitlist.dev/e/20080710014750.GA7714%40spearce.org
In-Reply-To: <alpine.DEB.1.00.0807092044120.4010@eeepc-johanness>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 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, 2008-07-10 02:32

Subject: Re: git protocol specification
Message-ID: <20080710023255.GA8061@spearce.org>
URL: https://gitlist.dev/e/20080710023255.GA8061%40spearce.org
In-Reply-To: <48750231.4020805@rubyisawesome.com>

```
Tom Werner <pubsub@rubyisawesome.com> 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. 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.

```
