libgit2/rugged — pull request #408 by nvloff (2014-08-31 20:46:46+00:00)
Title: Submodules redux

Second attempt at submodules. Went through rugged's history and tried to make this inline with the latest API additions, may have missed something.

Only thing missing is `git_submodule_branch`, but it would probably take me another year to add it, so skipping it for now.

A couple of implementation notes:
* The `git_submodule` passed to the callback of `git_submodule_foreach ` has it's refcount decreased just before `git_submodule_foreach` returns. Meaning that those references should not be used outside the foreach callback. A quite ugly and slow workaround I have is to lookup the module passed to the callback, just to increase it's refcount and ensure it's not prematurely freed.
* `git_submodule_add_setup` inits a new repo. This is incompatible both with libgit2's `git_clone` and `git clone`, as they both require the target dir for the clone to be empty. So submodules have a ghetto clone implementation that most probably has some different behaviour than `git_clone`.

Travis fails for some strange reason...