libgit2/libgit2 — pull request #1369 by arrbee (2013-02-26 21:28:00+00:00)
Title: More tests (and fixes) for initializing repo from template

When PR #1359 removed the hooks from the test resources/template directory, it made me realize that the tests for `git_repository_init_ext` using templates must be pretty shabby because we could not have been testing if the hooks were getting created correctly.

So, this started with me recreating a couple of hooks, including a sample and symlink, and adding tests that they got created correctly in the various circumstances, including with the SHARED modes, etc. Unfortunately this uncovered some issues with how directories and symlinks were copied and chmod'ed. Also, there was a FIXME in the code related to the chmod behavior as well to be resolved.

Going back over the directory creation logic for setting up a repository, I found it was a little difficult to read and could result in creating and/or chmod'ing directories that the user almost certainly didn't intend.

So that led to this PR which makes repo initialization more careful (and hopefully easier to follow). It required a couple of extensions / changes to core fileops utilities (mkdir and cp_r), but I also think those are for the better, at least for `git_futils_cp_r` in terms of being careful about what actions it takes.

And then I had to make it all work on Windows, too.