}\r
\r
String getValue() {\r
- if ( enumValue == GitConfigSharedRepositoryValue.Oxxx ) return Integer.toOctalString(intValue);\r
+ if ( enumValue == GitConfigSharedRepositoryValue.Oxxx ) {\r
+ if (intValue == 0) return "0";\r
+ return String.format("0%o", intValue);\r
+ }\r
return enumValue.getConfigValue();\r
}\r
\r
\r
if (configShared.isCustom()) {\r
// Use the custom value for access permissions.\r
- mode |= (mode & ~0777) | perm;\r
+ mode = (mode & ~0777) | perm;\r
}\r
else {\r
// Just add necessary bits to existing permissions.\r
}\r
}\r
\r
+ @Test\r
+ public void testCreateRepositorySharedCustom() throws Exception {\r
+ String[] repositories = { "NewSharedTestRepository.git" };\r
+ for (String repositoryName : repositories) {\r
+ Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES,\r
+ repositoryName, "660");\r
+ File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName),\r
+ FS.DETECTED);\r
+ assertNotNull(repository);\r
+ assertFalse(JGitUtils.hasCommits(repository));\r
+ assertNull(JGitUtils.getFirstCommit(repository, null));\r
+\r
+ assertEquals("0660", repository.getConfig().getString("core", null, "sharedRepository"));\r
+\r
+ assertTrue(folder.exists());\r
+ if (! JnaUtils.isWindows()) {\r
+ int mode = JnaUtils.getFilemode(folder);\r
+ assertEquals(JnaUtils.S_ISGID, mode & JnaUtils.S_ISGID);\r
+ assertEquals(JnaUtils.S_IRWXG, mode & JnaUtils.S_IRWXG);\r
+ assertEquals(0, mode & JnaUtils.S_IRWXO);\r
+\r
+ mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/HEAD");\r
+ assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);\r
+ assertEquals(0, mode & JnaUtils.S_IRWXO);\r
+\r
+ mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/config");\r
+ assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);\r
+ assertEquals(0, mode & JnaUtils.S_IRWXO);\r
+ }\r
+\r
+ repository.close();\r
+ RepositoryCache.close(repository);\r
+ FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);\r
+ }\r
+ }\r
+\r
@Test\r
public void testRefs() throws Exception {\r
Repository repository = GitBlitSuite.getJGitRepository();\r