Tell HN: HN driven development: libgit2 Postgres back end arrives

18 points by andrewstuart ↗ HN
I wanted to store git repos in Postgres.

My request for help hit the HN front page and within 2 hours of asking https://news.ycombinator.com/item?id=9833548 a complete (but untested) solution https://gist.github.com/mhodgson/d29bbd35e1a8db5e0800 was donated by an HN community member mhodgson.

So libgit2 now has a Postgres back end thanks to HN and HN user mhodgson!

Any C programmers with Postgres and/or git knowledge, it would be awesome if you posted your comments on the freshly open sourced code

HN driven development has taken off!

4 comments

[ 2.6 ms ] story [ 20.0 ms ] thread
FWIW I enjoyed the challenge of hacking up my own version of this. It's admittedly not battle-tested, but hey ;)

https://github.com/cbdevnet/libgit2-backends/blob/master/pos...

Awesome!

Incredible to get two implementations.

I really appreciate that you've made this happen.

Is this built from scratch or a port of one of the existing drivers? Did you have a chance to have a look at the other implementation - what do you see as the major differences?

Any thoughts of submitting to the libgit2 project?

I copied the prototypes and general structure of the driver from the existing ones (mainly the sqlite driver), implementing the functionality with the appropriate postgres API calls.

As for the implementation by mhodgson, one thing I noticed is that it uses the slightly newer PQexecPrepared API, which only works from protocol version 3.0 and upwards (which was introduced with PostgreSQL 7.4, so not really a problem). He also seems to use some more calls to the libgit2 API, mainly for copying and creating buffers for SQL statements (which I did with static allocation, at the expense of having hardcoded schema and table names).

All in all, mhodgson's implementation seems more feature-complete (and well-tested) than mine, yet also considerably more complex.

As for submitting it, I'd like to have some confirmation that it works first :) Unfortunately, I'm currently too busy to really set up some tests for it, but once I have the time, I just might ;)