From b1dba764c201f4708b82767b2d91edb6e189ce6f Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 22 Jul 2011 10:09:18 -0400 Subject: [PATCH] Fixed (again) empty repository check (issue 13) --- src/com/gitblit/utils/JGitUtils.java | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 2e14b67..03a5d00 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -80,6 +80,12 @@ import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; +/** + * Collection of static methods for retrieving information from a repository. + * + * @author James Moger + * + */ public class JGitUtils { static final Logger LOGGER = LoggerFactory.getLogger(JGitUtils.class); @@ -298,14 +304,14 @@ /** * Determine if a repository has any commits. This is determined by checking - * the objects/info and objects/pack folders. + * the for loose and packed objects. * * @param repository * @return true if the repository has commits */ public static boolean hasCommits(Repository repository) { - if (repository != null && repository.getDirectory().exists()) { - return (new File(repository.getDirectory(), "objects/info").list().length > 0) + if (repository != null && repository.getDirectory().exists()) { + return (new File(repository.getDirectory(), "objects").list().length > 2) || (new File(repository.getDirectory(), "objects/pack").list().length > 0); } return false; @@ -795,6 +801,9 @@ return list; } + /** + * Enumeration of the search types. + */ public static enum SearchType { AUTHOR, COMMITTER, COMMIT; -- Gitblit v1.9.1