From 3a067e5b667bb30b7ddd18f7860358d725f01219 Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Tue, 20 Aug 2013 13:41:20 +0200 Subject: [PATCH] Add new property git.createRepositoriesShared. --- src/main/distrib/data/gitblit.properties | 9 +++++++++ src/main/java/com/gitblit/GitBlit.java | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties index 9be7f645..724bcb62 100644 --- a/src/main/distrib/data/gitblit.properties +++ b/src/main/distrib/data/gitblit.properties @@ -174,6 +174,15 @@ git.defaultAuthorizationControl = NAMED # SINCE 1.3.0 git.defaultIncrementalPushTagPrefix = r +# In an Unix environment where mixed access methods exist for shared repositories, +# the repository should be created with 'git init --shared' to make sure that +# it can be accessed e.g. via ssh (user git) and http (user www-data). +# Valid values are the values available for the '--shared' option. The the manual +# page for 'git init' for more information on shared repositories. +# +# SINCE 1.3.2 +git.createRepositoriesShared = false + # Enable JGit-based garbage collection. (!!EXPERIMENTAL!!) # # USE AT YOUR OWN RISK! diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index 6ea348d5..67833822 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -2426,7 +2426,8 @@ public class GitBlit implements ServletContextListener { } // create repository logger.info("create repository " + repository.name); - r = JGitUtils.createRepository(repositoriesFolder, repository.name); + String shared = getString(Keys.git.createRepositoriesShared, "FALSE"); + r = JGitUtils.createRepository(repositoriesFolder, repository.name, shared); } else { // rename repository if (!repositoryName.equalsIgnoreCase(repository.name)) { @@ -2528,7 +2529,13 @@ public class GitBlit implements ServletContextListener { // close the repository object r.close(); } - + + // Adjust permissions in case we updated the config files + JGitUtils.adjustSharedPerm(new File(r.getDirectory().getAbsolutePath(), "config"), + getString(Keys.git.createRepositoriesShared, "FALSE")); + JGitUtils.adjustSharedPerm(new File(r.getDirectory().getAbsolutePath(), "HEAD"), + getString(Keys.git.createRepositoriesShared, "FALSE")); + // update repository cache removeFromCachedRepositoryList(repositoryName); // model will actually be replaced on next load because config is stale -- 2.39.5