summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-12-26 22:39:22 -0600
committerEdward Thomson <ethomson@edwardthomson.com>2015-12-26 22:41:00 -0600
commit62602547db2301493cf9681e3a76016ceb1e0b8b (patch)
treeb701e1f59526a3fec0c8b829ad99e381b2d97a22
parent002821837f0dd8d57c6c03b11159dff060cb1982 (diff)
downloadlibgit2-62602547db2301493cf9681e3a76016ceb1e0b8b.tar.gz
git_repository_init: include dotfiles when copying templates
Include dotfiles when copying template directory, which will handle both a template directory itself that begins with a dotfile, and any dotfiles inside the directory.
-rw-r--r--src/repository.c4
-rw-r--r--tests/repo/init.c13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/repository.c b/src/repository.c
index 6234cd595..8a6fef0f6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1438,7 +1438,9 @@ static int repo_init_structure(
}
if (tdir) {
- uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_SIMPLE_TO_MODE;
+ uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS |
+ GIT_CPDIR_SIMPLE_TO_MODE |
+ GIT_CPDIR_COPY_DOTFILES;
if (opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK)
cpflags |= GIT_CPDIR_CHMOD_DIRS;
error = git_futils_cp_r(tdir, repo_dir, cpflags, dmode);
diff --git a/tests/repo/init.c b/tests/repo/init.c
index b06a81347..04d4a5c5e 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -519,7 +519,8 @@ static void assert_mode_seems_okay(
static const char *template_sandbox(const char *name)
{
- git_buf hooks_path = GIT_BUF_INIT, link_path = GIT_BUF_INIT;
+ git_buf hooks_path = GIT_BUF_INIT, link_path = GIT_BUF_INIT,
+ dotfile_path = GIT_BUF_INIT;
const char *path = cl_fixture(name);
cl_fixture_sandbox(name);
@@ -537,6 +538,12 @@ static const char *template_sandbox(const char *name)
cl_must_pass(symlink("update.sample", link_path.ptr));
#endif
+ /* create a file starting with a dot */
+ cl_git_pass(git_buf_joinpath(&dotfile_path, hooks_path.ptr, ".dotfile"));
+ cl_git_mkfile(dotfile_path.ptr, "something\n");
+ git_buf_free(&dotfile_path);
+
+ git_buf_free(&dotfile_path);
git_buf_free(&link_path);
git_buf_free(&hooks_path);
@@ -595,6 +602,10 @@ static void validate_templates(git_repository *repo, const char *template_path)
template_path, git_repository_path(repo),
"hooks/link.sample", filemode);
+ assert_hooks_match(
+ template_path, git_repository_path(repo),
+ "hooks/.dotfile", filemode);
+
git_buf_free(&expected);
git_buf_free(&actual);
git_buf_free(&repo_description);