WIP: andrioni's Libgit2 work

I'm making this into a pull request for easier discussion and so that I can check it out more easily.