diff options
author | Vicent Marti <vicent@github.com> | 2014-05-28 13:50:58 +0200 |
---|---|---|
committer | Vicent Marti <vicent@github.com> | 2014-05-28 13:50:58 +0200 |
commit | 07c0eacd878a07b4107a41b3e3f84c5c6dc4136b (patch) | |
tree | 826541ddf449f126ac47cbe528133a2a99829d84 | |
parent | ab882e21b4805f826b91763e50b05c21b634b9b2 (diff) | |
parent | 517341c5d8b316f5590d55a4913a65c78ab05973 (diff) | |
download | libgit2-07c0eacd878a07b4107a41b3e3f84c5c6dc4136b.tar.gz |
Merge pull request #2359 from e45lee/chmod-fix
Fixed permissions on template directories.
-rw-r--r-- | src/repository.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/repository.c b/src/repository.c index b0db5484a..e8d50aed3 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1190,6 +1190,7 @@ static int repo_init_structure( bool external_tpl = ((opts->flags & GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE) != 0); mode_t dmode = pick_dir_mode(opts); + bool chmod = opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK; /* Hide the ".git" directory */ #ifdef GIT_WIN32 @@ -1230,10 +1231,12 @@ static int repo_init_structure( default_template = true; } - if (tdir) - error = git_futils_cp_r(tdir, repo_dir, - GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_CHMOD_DIRS | - GIT_CPDIR_SIMPLE_TO_MODE, dmode); + if (tdir) { + uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_SIMPLE_TO_MODE; + if (opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK) + cpflags |= GIT_CPDIR_CHMOD_DIRS; + error = git_futils_cp_r(tdir, repo_dir, cpflags, dmode); + } git_buf_free(&template_buf); git_config_free(cfg); @@ -1254,9 +1257,14 @@ static int repo_init_structure( * - only create files if no external template was specified */ for (tpl = repo_template; !error && tpl->path; ++tpl) { - if (!tpl->content) + if (!tpl->content) { + uint32_t mkdir_flags = GIT_MKDIR_PATH; + if (chmod) + mkdir_flags |= GIT_MKDIR_CHMOD; + error = git_futils_mkdir( - tpl->path, repo_dir, dmode, GIT_MKDIR_PATH | GIT_MKDIR_CHMOD); + tpl->path, repo_dir, dmode, mkdir_flags); + } else if (!external_tpl) { const char *content = tpl->content; |