# Git Servlet Settings\r
#\r
\r
-# Base folder for repositories\r
+# Base folder for repositories.\r
+# This folder may contain bare and non-bare repositories but Gitblit will only\r
+# allow you to push to bare repositories.\r
# Use forward slashes even on Windows!!\r
# e.g. c:/gitrepos\r
#\r
# SINCE 0.5.0\r
git.enableGitServlet = true\r
\r
+# Only serve/display bare repositories.\r
+# If there are non-bare repositories in git.repositoriesFolder and this setting\r
+# is true, they will be excluded from the ui. \r
+#\r
+# SINCE 0.9.0\r
+git.onlyAccessBareRepositories = false\r
+\r
#\r
# Groovy Integration\r
#\r
\r
private File repositoriesFolder;\r
\r
- private boolean exportAll = true;\r
-\r
private IUserService userService;\r
\r
private IStoredSettings settings;\r
* @return list of all repositories\r
*/\r
public List<String> getRepositoryList() {\r
- return JGitUtils.getRepositoryList(repositoriesFolder, exportAll,\r
+ return JGitUtils.getRepositoryList(repositoriesFolder, \r
+ settings.getBoolean(Keys.git.onlyAccessBareRepositories, false),\r
settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true));\r
}\r
\r
this.settings = settings;\r
repositoriesFolder = getRepositoriesFolder();\r
logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());\r
- repositoryResolver = new FileResolver<Void>(repositoriesFolder, exportAll);\r
+ repositoryResolver = new FileResolver<Void>(repositoriesFolder, true);\r
serverStatus = new ServerStatus(isGO());\r
String realm = settings.getString(Keys.realm.userService, "users.properties");\r
IUserService loginService = null;\r
* Returns a list of repository names in the specified folder.\r
* \r
* @param repositoriesFolder\r
- * @param exportAll\r
- * if true, all repositories are listed. If false only the\r
- * repositories with a "git-daemon-export-ok" file are included\r
+ * @param onlyBare\r
+ * if true, only bare repositories repositories are listed. If\r
+ * false all repositories are included.\r
* @param searchSubfolders\r
* recurse into subfolders to find grouped repositories\r
* @return list of repository names\r
*/\r
- public static List<String> getRepositoryList(File repositoriesFolder, boolean exportAll,\r
+ public static List<String> getRepositoryList(File repositoriesFolder, boolean onlyBare,\r
boolean searchSubfolders) {\r
List<String> list = new ArrayList<String>();\r
if (repositoriesFolder == null || !repositoriesFolder.exists()) {\r
return list;\r
}\r
list.addAll(getRepositoryList(repositoriesFolder.getAbsolutePath(), repositoriesFolder,\r
- exportAll, searchSubfolders));\r
+ onlyBare, searchSubfolders));\r
StringUtils.sortRepositorynames(list);\r
return list;\r
}\r
* basePath is stripped from the repository name as repositories\r
* are relative to this path\r
* @param searchFolder\r
- * @param exportAll\r
- * if true all repositories are listed. If false only the\r
- * repositories with a "git-daemon-export-ok" file are included\r
+ * @param onlyBare\r
+ * if true only bare repositories will be listed. if false all\r
+ * repositories are included.\r
* @param searchSubfolders\r
* recurse into subfolders to find grouped repositories\r
* @return\r
*/\r
private static List<String> getRepositoryList(String basePath, File searchFolder,\r
- boolean exportAll, boolean searchSubfolders) {\r
+ boolean onlyBare, boolean searchSubfolders) {\r
List<String> list = new ArrayList<String>();\r
for (File file : searchFolder.listFiles()) {\r
if (file.isDirectory()) {\r
File gitDir = FileKey.resolve(new File(searchFolder, file.getName()), FS.DETECTED);\r
if (gitDir != null) {\r
- boolean exportRepository = exportAll\r
- || new File(gitDir, "git-daemon-export-ok").exists();\r
-\r
- if (!exportRepository) {\r
+ if (onlyBare && gitDir.getName().equals(".git")) {\r
continue;\r
}\r
// determine repository name relative to base path\r
list.add(repository);\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
- list.addAll(getRepositoryList(basePath, file, exportAll, searchSubfolders));\r
+ list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders));\r
}\r
}\r
}\r