libgit2/libgit2 — pull request #844 by arrbee (2012-07-26 23:28:30+00:00)
Title: Add git_repository_init_ext for power initters

The new `git_repository_init_ext` adds support for many of the things that you can do with `git init` and sets up structures that will make it easier to extend further in the future. It is documented in `include/git2/repository.h` reasonably well, I think.

My motivation for adding this was to make it easier for the submodule code to create a repository where the repo dir was `/.git/modules/` and the working directory was `/`. Using the new function, you can explicitly set the repo dir and working dir, and init is smart enough to automatically make the gitlink between them.

Additionally, this gives more fine grained control over many of the other things that can be tweaked in `git init`.

This PR is not ready to be merged. The main issue is that most of the new features don't have tests written for them. Also, there are a couple of features that are implied by the new extended flags that are not implemented yet (such as support for copying template files out of an external directory). I have tested the parts of the new functionality that are used by submodules, but that code is really orthogonal to this (and I haven't included it in this PR).

One thing that surprised me a little while writing this was that the behavior of `git_repository_init` is to create the full path to the repository if it does not exist. I also implemented two less aggressive directory creation modes (i.e. just create the ".git" directory and just create ".git" and its immediate parent directory). Don't know if the new modes matter - I mostly wrote them because I didn't realize that creating the full path was the existing behavior.