From: Johan Herland Date: Wed, 25 Mar 2009 21:41:23 GMT Subject: [PATCH/RFC 6/7] git-init: Apply correct mode bits to template files in shared/restricted repo Message-ID: <200903252241.23302.johan@herland.net> In-Reply-To: <200903252236.03010.johan@herland.net> Template dirs/files are copied into the new repo before the config file is parsed. This causes them to be created with default permissions (i.e. from umask). When "--shared" and/or "--restricted" is given, this patch teaches git-init to initialize the global variables controlling permissions on created files (shared_repository and/or restricted_repository) _before_ the templates are copied. They are thus created with the appropriate permissions. Signed-off-by: Johan Herland --- builtin-init-db.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/builtin-init-db.c b/builtin-init-db.c index 8e7fa2d..fb88f65 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -187,6 +187,15 @@ static int create_default_files(const char *template_path) safe_create_dir(git_path("refs/heads"), 1); safe_create_dir(git_path("refs/tags"), 1); + /* + * Set up shared/restricted_repository before copying templates, so + * that they are created with appropriate permissions. + */ + if (init_shared_repository != -1) + shared_repository = init_shared_repository; + if (init_restricted_repository != -1) + restricted_repository = init_restricted_repository; + /* First copy the templates -- we might have the default * config file there, in which case we would want to read * from it after installing. -- 1.6.2.1.473.g92672