]> source.dussan.org Git - gitblit.git/commitdiff
Add new property git.createRepositoriesShared.
authorFlorian Zschocke <florian.zschocke@cycos.com>
Tue, 20 Aug 2013 11:41:20 +0000 (13:41 +0200)
committerFlorian Zschocke <florian.zschocke@cycos.com>
Mon, 26 Aug 2013 10:39:57 +0000 (12:39 +0200)
src/main/distrib/data/gitblit.properties
src/main/java/com/gitblit/GitBlit.java

index 9be7f645ddff37112f00f2d5ed52c38064179232..724bcb621ed4c4b18d34b646a1caf513e6bec03b 100644 (file)
@@ -174,6 +174,15 @@ git.defaultAuthorizationControl = NAMED
 # SINCE 1.3.0\r
 git.defaultIncrementalPushTagPrefix = r\r
 \r
+# In an Unix environment where mixed access methods exist for shared repositories,\r
+# the repository should be created with 'git init --shared' to make sure that\r
+# it can be accessed e.g. via ssh (user git) and http (user www-data).\r
+# Valid values are the values available for the '--shared' option. The the manual\r
+# page for 'git init' for more information on shared repositories.\r
+#\r
+# SINCE 1.3.2\r
+git.createRepositoriesShared = false\r
+\r
 # Enable JGit-based garbage collection. (!!EXPERIMENTAL!!)\r
 #\r
 # USE AT YOUR OWN RISK!\r
index 6ea348d511eeb81c37fa512403762d10c590b6c9..6783382243b08cef3501167675695cdfc093d4c9 100644 (file)
@@ -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