James Moger
2013-04-15 843c42bafae020e2e0e6d49befc6db960f61c66c
Completed migration to JGit 3.0.0-SNAPSHOT
11 files modified
111 ■■■■■ changed files
.classpath 5 ●●●●● patch | view | raw | blame | history
build.moxie 4 ●●●● patch | view | raw | blame | history
gitblit.iml 23 ●●●● patch | view | raw | blame | history
releases.moxie 5 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/AddIndexedBranch.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/GCExecutor.java 26 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/GitBlit.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/utils/JGitUtils.java 3 ●●●● patch | view | raw | blame | history
src/test/java/com/gitblit/tests/GitBlitSuite.java 22 ●●●●● patch | view | raw | blame | history
src/test/java/com/gitblit/tests/GitServletTest.java 5 ●●●●● patch | view | raw | blame | history
src/test/java/com/gitblit/tests/PushLogTest.java 8 ●●●● patch | view | raw | blame | history
.classpath
@@ -21,9 +21,10 @@
    <classpathentry kind="lib" path="ext/lucene-queries-3.6.1.jar" sourcepath="ext/src/lucene-queries-3.6.1.jar" />
    <classpathentry kind="lib" path="ext/jakarta-regexp-1.4.jar" />
    <classpathentry kind="lib" path="ext/markdownpapers-core-1.3.2.jar" sourcepath="ext/src/markdownpapers-core-1.3.2.jar" />
    <classpathentry kind="lib" path="ext/org.eclipse.jgit-2.3.1.201302201838-r.jar" sourcepath="ext/src/org.eclipse.jgit-2.3.1.201302201838-r.jar" />
    <classpathentry kind="lib" path="ext/org.eclipse.jgit-3.0.0-SNAPSHOT.jar" sourcepath="ext/src/org.eclipse.jgit-3.0.0-SNAPSHOT.jar" />
    <classpathentry kind="lib" path="ext/jsch-0.1.46.jar" sourcepath="ext/src/jsch-0.1.46.jar" />
    <classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-2.3.1.201302201838-r.jar" sourcepath="ext/src/org.eclipse.jgit.http.server-2.3.1.201302201838-r.jar" />
    <classpathentry kind="lib" path="ext/JavaEWAH-0.5.6.jar" sourcepath="ext/src/JavaEWAH-0.5.6.jar" />
    <classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-3.0.0-SNAPSHOT.jar" sourcepath="ext/src/org.eclipse.jgit.http.server-3.0.0-SNAPSHOT.jar" />
    <classpathentry kind="lib" path="ext/bcprov-jdk15on-1.47.jar" sourcepath="ext/src/bcprov-jdk15on-1.47.jar" />
    <classpathentry kind="lib" path="ext/bcmail-jdk15on-1.47.jar" sourcepath="ext/src/bcmail-jdk15on-1.47.jar" />
    <classpathentry kind="lib" path="ext/bcpkix-jdk15on-1.47.jar" sourcepath="ext/src/bcpkix-jdk15on-1.47.jar" />
build.moxie
@@ -3,14 +3,14 @@
#
# Specify minimum Moxie version required to build
requires: 0.7.1
requires: 0.7.2
# Project Metadata
name: Gitblit
description: pure Java Git solution
groupId: com.gitblit
artifactId: gitblit
version: 1.4.0-SNAPSHOT
version: 1.3.0-SNAPSHOT
inceptionYear: 2011
# Current stable release
gitblit.iml
@@ -207,13 +207,13 @@
      </library>
    </orderEntry>
    <orderEntry type="module-library">
      <library name="org.eclipse.jgit-2.3.1.201302201838-r.jar">
      <library name="org.eclipse.jgit-3.0.0-SNAPSHOT.jar">
        <CLASSES>
          <root url="jar://$MODULE_DIR$/ext/org.eclipse.jgit-2.3.1.201302201838-r.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/org.eclipse.jgit-3.0.0-SNAPSHOT.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://$MODULE_DIR$/ext/src/org.eclipse.jgit-2.3.1.201302201838-r.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/src/org.eclipse.jgit-3.0.0-SNAPSHOT.jar!/" />
        </SOURCES>
      </library>
    </orderEntry>
@@ -229,13 +229,24 @@
      </library>
    </orderEntry>
    <orderEntry type="module-library">
      <library name="org.eclipse.jgit.http.server-2.3.1.201302201838-r.jar">
      <library name="JavaEWAH-0.5.6.jar">
        <CLASSES>
          <root url="jar://$MODULE_DIR$/ext/org.eclipse.jgit.http.server-2.3.1.201302201838-r.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/JavaEWAH-0.5.6.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://$MODULE_DIR$/ext/src/org.eclipse.jgit.http.server-2.3.1.201302201838-r.jar!/" />
          <root url="jar://$MODULE_DIR$/ext/src/JavaEWAH-0.5.6.jar!/" />
        </SOURCES>
      </library>
    </orderEntry>
    <orderEntry type="module-library">
      <library name="org.eclipse.jgit.http.server-3.0.0-SNAPSHOT.jar">
        <CLASSES>
          <root url="jar://$MODULE_DIR$/ext/org.eclipse.jgit.http.server-3.0.0-SNAPSHOT.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://$MODULE_DIR$/ext/src/org.eclipse.jgit.http.server-3.0.0-SNAPSHOT.jar!/" />
        </SOURCES>
      </library>
    </orderEntry>
releases.moxie
@@ -25,6 +25,8 @@
     - Use standard ServletRequestWrapper instead of custom wrapper (issue 224)
    changes:
      - Disable Gson's pretty printing which has a huge performance gain
     - Properly set application/json content-type on api calls
     - Updated Polish translation
     
    additions: 
@@ -44,6 +46,7 @@
    contributors:
    - Bandarupalli Satyanarayana
    - Christian Aistleitner
    - David Ostrovsky
    - Egbert Teeselink
    - Hige Maniya
    - Ikslawek
@@ -67,7 +70,7 @@
    - github/dapengme
    
    dependencyChanges:
    - JGit 2.3.1.201302201838-r
    - JGit 3.0.0-SNAPSHOT
    
    settings:
    - { name: 'git.daemonBindInterface', defaultValue: 'localhost' }
src/main/java/com/gitblit/AddIndexedBranch.java
@@ -25,9 +25,8 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.util.FS;
import com.beust.jcommander.JCommander;
@@ -88,8 +87,8 @@
            try {
                // load repository config
                File gitDir = FileKey.resolve(new File(folder, repo), FS.DETECTED);
                FileRepository repository = (FileRepository)new FileRepositoryBuilder().setGitDir(gitDir).build();
                FileBasedConfig config = repository.getConfig();
                Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
                StoredConfig config = repository.getConfig();
                config.load();
                
                Set<String> indexedBranches = new LinkedHashSet<String>();
src/main/java/com/gitblit/GCExecutor.java
@@ -20,14 +20,14 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jgit.api.GarbageCollectCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.internal.storage.file.GC;
import org.eclipse.jgit.internal.storage.file.GC.RepoStatistics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -141,10 +141,10 @@
            }
            boolean garbageCollected = false;
            RepositoryModel model = null;
            FileRepository repository = null;
            Repository repository = null;
            try {
                model = GitBlit.self().getRepositoryModel(repositoryName);
                repository = (FileRepository) GitBlit.self().getRepository(repositoryName);
                repository = GitBlit.self().getRepository(repositoryName);
                if (repository == null) {
                    logger.warn(MessageFormat.format("GCExecutor is missing repository {0}?!?", repositoryName));
                    continue;
@@ -165,8 +165,9 @@
                
                logger.debug(MessageFormat.format("GCExecutor locked idle repository {0}", repositoryName));
                
                GC gc = new GC(repository);
                RepoStatistics stats = gc.getStatistics();
                Git git = new Git(repository);
                GarbageCollectCommand gc = git.gc();
                Properties stats = gc.getStatistics();
                
                // determine if this is a scheduled GC
                Calendar cal = Calendar.getInstance();
@@ -181,16 +182,17 @@
                // determine if filesize triggered GC
                long gcThreshold = FileUtils.convertSizeToLong(model.gcThreshold, 500*1024L);
                boolean hasEnoughGarbage = stats.sizeOfLooseObjects >= gcThreshold;
                long sizeOfLooseObjects = (Long) stats.get("sizeOfLooseObjects");
                boolean hasEnoughGarbage = sizeOfLooseObjects >= gcThreshold;
                // if we satisfy one of the requirements, GC
                boolean hasGarbage = stats.sizeOfLooseObjects > 0;
                boolean hasGarbage = sizeOfLooseObjects > 0;
                if (hasGarbage && (hasEnoughGarbage || shouldCollectGarbage)) {
                    long looseKB = stats.sizeOfLooseObjects/1024L;
                    long looseKB = sizeOfLooseObjects/1024L;
                    logger.info(MessageFormat.format("Collecting {1} KB of loose objects from {0}", repositoryName, looseKB));
                    
                    // do the deed
                    gc.gc();
                    gc.call();
                    
                    garbageCollected = true;
                }
@@ -217,7 +219,7 @@
        running.set(false);
    }
    
    private boolean isRepositoryIdle(FileRepository repository) {
    private boolean isRepositoryIdle(Repository repository) {
        try {
            // Read the use count.
            // An idle use count is 2:
src/main/java/com/gitblit/GitBlit.java
@@ -71,7 +71,6 @@
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.internal.storage.file.WindowCache;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
@@ -3186,7 +3185,7 @@
        cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
        try {
            WindowCache.reconfigure(cfg);
            cfg.install();
            logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
            logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
            logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
src/main/java/com/gitblit/utils/JGitUtils.java
@@ -67,7 +67,6 @@
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter;
import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.FetchResult;
@@ -199,7 +198,7 @@
        File folder = new File(repositoriesFolder, name);
        if (folder.exists()) {
            File gitDir = FileKey.resolve(new File(repositoriesFolder, name), FS.DETECTED);
            FileRepository repository = (FileRepository)new FileRepositoryBuilder().setGitDir(gitDir).build();
            Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
            result.fetchResult = fetchRepository(credentialsProvider, repository);
            repository.close();
        } else {
src/test/java/com/gitblit/tests/GitBlitSuite.java
@@ -25,7 +25,7 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache;
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FS;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -78,32 +78,38 @@
    private static AtomicBoolean started = new AtomicBoolean(false);
    public static Repository getHelloworldRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "helloworld.git"));
        return getRepository("helloworld.git");
    }
    public static Repository getTicgitRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "ticgit.git"));
        return getRepository("ticgit.git");
    }
    public static Repository getJGitRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "test/jgit.git"));
        return getRepository("test/jgit.git");
    }
    public static Repository getAmbitionRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "test/ambition.git"));
        return getRepository("test/ambition.git");
    }
    public static Repository getTheoreticalPhysicsRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "test/theoretical-physics.git"));
        return getRepository("test/theoretical-physics.git");
    }
    public static Repository getIssuesTestRepository() throws Exception {
        JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();
        return new FileRepository(new File(REPOSITORIES, "gb-issues.git"));
        return getRepository("gb-issues.git");
    }
    
    public static Repository getGitectiveRepository() throws Exception {
        return new FileRepository(new File(REPOSITORIES, "test/gitective.git"));
        return getRepository("test/gitective.git");
    }
    private static Repository getRepository(String name) throws Exception {
        File gitDir = FileKey.resolve(new File(REPOSITORIES, name), FS.DETECTED);
        Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
        return repository;
    }
    public static boolean startGitblit() throws Exception {
src/test/java/com/gitblit/tests/GitServletTest.java
@@ -19,8 +19,9 @@
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.RefSpec;
@@ -786,7 +787,7 @@
    public void testPushLog() throws IOException {
        String name = "refchecks/ticgit.git";
        File refChecks = new File(GitBlitSuite.REPOSITORIES, name);
        FileRepository repository = new FileRepository(refChecks);
        Repository repository = new FileRepositoryBuilder().setGitDir(refChecks).build();
        List<PushLogEntry> pushes = PushLogUtils.getPushLog(name, repository);
        GitBlitSuite.close(repository);
        assertTrue("Repository has an empty push log!", pushes.size() > 0);
src/test/java/com/gitblit/tests/PushLogTest.java
@@ -19,7 +19,10 @@
import java.io.IOException;
import java.util.List;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FS;
import org.junit.Test;
import com.gitblit.models.PushLogEntry;
@@ -30,7 +33,8 @@
    @Test
    public void testPushLog() throws IOException {
        String name = "~james/helloworld.git";
        FileRepository repository = new FileRepository(new File(GitBlitSuite.REPOSITORIES, name));
        File gitDir = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, name), FS.DETECTED);
        Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
        List<PushLogEntry> pushes = PushLogUtils.getPushLog(name, repository);
        GitBlitSuite.close(repository);
    }