summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/04_releases.mkd1
-rw-r--r--src/com/gitblit/GitBlit.java25
2 files changed, 16 insertions, 10 deletions
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index 30582d53..ffd56ddc 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t
#### fixes
+- Fixed duplicate entries in repository cache (issue 140)
- Fixed connection leak in LDAPUserService (issue 139)
- Fixed bug in commit page where changes to a submodule threw a null pointer exception (issue 132)
- Fixed bug in the diff view for filenames that have non-ASCII characters (issue 128)
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 63489643..b14adc97 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -746,17 +746,17 @@ public class GitBlit implements ServletContextListener {
* Adds the repository to the list of cached repositories if Gitblit is
* configured to cache the repository list.
*
- * @param name
+ * @param model
*/
- private void addToCachedRepositoryList(String name, RepositoryModel model) {
+ private void addToCachedRepositoryList(RepositoryModel model) {
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
- repositoryListCache.put(name, model);
+ repositoryListCache.put(model.name, model);
// update the fork origin repository with this repository clone
if (!StringUtils.isEmpty(model.originRepository)) {
if (repositoryListCache.containsKey(model.originRepository)) {
RepositoryModel origin = repositoryListCache.get(model.originRepository);
- origin.addFork(name);
+ origin.addFork(model.name);
}
}
}
@@ -1001,7 +1001,7 @@ public class GitBlit implements ServletContextListener {
if (model == null) {
return null;
}
- addToCachedRepositoryList(repositoryName, model);
+ addToCachedRepositoryList(model);
return model;
}
@@ -1023,7 +1023,7 @@ public class GitBlit implements ServletContextListener {
logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
model = loadRepositoryModel(repositoryName);
removeFromCachedRepositoryList(repositoryName);
- addToCachedRepositoryList(repositoryName, model);
+ addToCachedRepositoryList(model);
} else {
// update a few repository parameters
if (!model.hasCommits) {
@@ -1236,10 +1236,15 @@ public class GitBlit implements ServletContextListener {
return null;
}
RepositoryModel model = new RepositoryModel();
- model.name = repositoryName;
+ model.isBare = r.isBare();
+ File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");
+ if (model.isBare) {
+ model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());
+ } else {
+ model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
+ }
model.hasCommits = JGitUtils.hasCommits(r);
model.lastChange = JGitUtils.getLastChange(r);
- model.isBare = r.isBare();
if (repositoryName.indexOf('/') == -1) {
model.projectPath = "";
} else {
@@ -1670,7 +1675,7 @@ public class GitBlit implements ServletContextListener {
// update repository cache
removeFromCachedRepositoryList(repositoryName);
// model will actually be replaced on next load because config is stale
- addToCachedRepositoryList(repository.name, repository);
+ addToCachedRepositoryList(repository);
}
/**
@@ -2678,7 +2683,7 @@ public class GitBlit implements ServletContextListener {
}
// add this clone to the cached model
- addToCachedRepositoryList(cloneModel.name, cloneModel);
+ addToCachedRepositoryList(cloneModel);
return cloneModel;
}
}