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!