libgit2/libgit2 — pull request #1790 by arrbee (2013-08-16 22:11:22+00:00)
Title: Add "git init"-like example

This adds a new example that emulates most of "git init".

There are a couple of cases that aren't emulated exactly related to looking at various environment variables and global configuration settings to decide where things should be created and which templates should be used. But that would add a lot of code that would largely not be relevant to the libgit2 API usage parts.

So make the example more useful, this adds a new flag on top of what git-init provides `--initial-commit` that creates an initial empty commit in the repository. This allowed me to expand the example to show how to make a simple commit which I hope will make it more useful to people.

As part of this, I realized that one of the biggest blockers to quickly creating a commit was having to create the fake signature, so I added a new `git_signature_default()` API that creates a signature for a repository by looking up the "user.name" and "user.email" configuration values (and also uses "now" for the time of the signature). This involved fairly little code and should streamline getting things up and running for folks creating commits.

Lastly, I added a test to the test suite that does the same thing: initialize a repo, create a file, create an initial commit with that file. That is largely driven by #1786 and making sure the test code there can actually run without error.