aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-07-22 11:17:00 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-07-22 14:56:34 -0700
commitfa9b225e06f16ca7fd7ffca5689f4af0942a73e1 (patch)
treed85054426a826f9b1495186d41252d0130f33407 /org.eclipse.jgit.pgm/src/org
parentab062caa2255054cca413985bbaa3ad7c1c9c383 (diff)
parent12fe0f2d1eb18aab2964532e99d11d4311d558eb (diff)
downloadjgit-fa9b225e06f16ca7fd7ffca5689f4af0942a73e1.tar.gz
jgit-fa9b225e06f16ca7fd7ffca5689f4af0942a73e1.zip
Merge branch 'delta'
* delta: (103 commits) Discard the uncompressed delta as soon as its compressed Honor pack.windowlimit to cap memory usage during packing Honor pack.threads and perform delta search in parallel Cache small deltas during packing Implement delta generation during packing debug-show-packdelta: Dump a pack delta to the console Initial pack format delta generator Add debugging toString() method to ObjectToPack Make ObjectToPack clearReuseAsIs signal available to subclasses Correctly classify the compressing objects phase Refactor ObjectToPack's delta depth setting Configure core.bigFileThreshold into PackWriter Add doNotDelta flag to ObjectToPack Add more configuration options to PackWriter Save object path hash codes during packing Add path hash code to ObjectWalk Add getObjectSize to ObjectReader Allow TemporaryBuffer.Heap to allocate smaller than 8 KiB Define a constant for 127 in DeltaEncoder Cap delta copy instructions at 64k ... Conflicts: org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java Change-Id: I7c7a05e443a48d32c836173a409ee7d340c70796
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java21
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java8
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java76
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java18
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java9
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java26
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java127
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java6
19 files changed, 200 insertions, 121 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
index b0f51ec58a..22302bba81 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
@@ -61,10 +61,10 @@ import org.eclipse.jgit.lib.GitIndex;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefComparator;
import org.eclipse.jgit.lib.RefUpdate;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.lib.Tree;
import org.eclipse.jgit.lib.WorkDirCheckout;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
@@ -82,6 +82,8 @@ class Clone extends AbstractFetchCommand {
@Argument(index = 1, metaVar = "metaVar_directory")
private String localName;
+ private FileRepository dst;
+
@Override
protected final boolean requiresRepository() {
return false;
@@ -103,10 +105,11 @@ class Clone extends AbstractFetchCommand {
if (gitdir == null)
gitdir = new File(localName, Constants.DOT_GIT);
- db = new Repository(gitdir);
- db.create();
- db.getConfig().setBoolean("core", null, "bare", false);
- db.getConfig().save();
+ dst = new FileRepository(gitdir);
+ dst.create();
+ dst.getConfig().setBoolean("core", null, "bare", false);
+ dst.getConfig().save();
+ db = dst;
out.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath());
out.println();
@@ -120,13 +123,13 @@ class Clone extends AbstractFetchCommand {
private void saveRemote(final URIish uri) throws URISyntaxException,
IOException {
- final RemoteConfig rc = new RemoteConfig(db.getConfig(), remoteName);
+ final RemoteConfig rc = new RemoteConfig(dst.getConfig(), remoteName);
rc.addURI(uri);
rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
.setSourceDestination(Constants.R_HEADS + "*",
Constants.R_REMOTES + remoteName + "/*"));
- rc.update(db.getConfig());
- db.getConfig().save();
+ rc.update(dst.getConfig());
+ dst.getConfig().save();
}
private FetchResult runFetch() throws NotSupportedException,
@@ -180,7 +183,7 @@ class Clone extends AbstractFetchCommand {
final Tree tree = commit.getTree();
final WorkDirCheckout co;
- co = new WorkDirCheckout(db, db.getWorkDir(), index, tree);
+ co = new WorkDirCheckout(db, db.getWorkTree(), index, tree);
co.checkout();
index.write();
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
index 3dfd8ff62d..ae11f67317 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
@@ -125,10 +125,12 @@ class Glog extends RevWalkTextBuiltin {
}
private String repoName() {
- final File f = db.getDirectory();
- String n = f.getName();
+ final File gitDir = db.getDirectory();
+ if (gitDir == null)
+ return db.toString();
+ String n = gitDir.getName();
if (Constants.DOT_GIT.equals(n))
- n = f.getParentFile().getName();
+ n = gitDir.getParentFile().getName();
return n;
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
index 35fd2a5971..640c8ef348 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
@@ -49,6 +49,7 @@ import java.io.File;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
+import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.TextProgressMonitor;
class IndexPack extends TextBuiltin {
@@ -64,7 +65,8 @@ class IndexPack extends TextBuiltin {
@Override
protected void run() throws Exception {
if (indexVersion == -1)
- indexVersion = db.getConfig().getCore().getPackIndexVersion();
+ indexVersion = db.getConfig().get(CoreConfig.KEY)
+ .getPackIndexVersion();
final BufferedInputStream in;
final org.eclipse.jgit.transport.IndexPack ip;
in = new BufferedInputStream(System.in);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
index d8c7bdfb4a..c5a696a57f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
@@ -50,7 +50,7 @@ import java.text.MessageFormat;
import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
@Command(common = true, usage = "usage_CreateAnEmptyGitRepository")
class Init extends TextBuiltin {
@@ -66,7 +66,7 @@ class Init extends TextBuiltin {
protected void run() throws Exception {
if (gitdir == null)
gitdir = new File(bare ? "." : Constants.DOT_GIT);
- db = new Repository(gitdir);
+ db = new FileRepository(gitdir);
db.create(bare);
out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()));
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
index 306ac816d8..ab11062cc2 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
@@ -51,20 +51,15 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.jgit.awtui.AwtAuthenticator;
import org.eclipse.jgit.awtui.AwtSshSessionFactory;
import org.eclipse.jgit.errors.TransportException;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryBuilder;
import org.eclipse.jgit.pgm.opt.CmdLineParser;
import org.eclipse.jgit.pgm.opt.SubcommandHandler;
import org.eclipse.jgit.util.CachedAuthenticator;
-import org.eclipse.jgit.util.SystemReader;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.ExampleMode;
@@ -168,51 +163,17 @@ public class Main {
final TextBuiltin cmd = subcommand;
if (cmd.requiresRepository()) {
- if (gitdir == null) {
- String gitDirEnv = SystemReader.getInstance().getenv(Constants.GIT_DIR_KEY);
- if (gitDirEnv != null)
- gitdir = new File(gitDirEnv);
- }
- if (gitdir == null)
- gitdir = findGitDir();
-
- File gitworktree;
- String gitWorkTreeEnv = SystemReader.getInstance().getenv(Constants.GIT_WORK_TREE_KEY);
- if (gitWorkTreeEnv != null)
- gitworktree = new File(gitWorkTreeEnv);
- else
- gitworktree = null;
-
- File indexfile;
- String indexFileEnv = SystemReader.getInstance().getenv(Constants.GIT_INDEX_KEY);
- if (indexFileEnv != null)
- indexfile = new File(indexFileEnv);
- else
- indexfile = null;
-
- File objectdir;
- String objectDirEnv = SystemReader.getInstance().getenv(Constants.GIT_OBJECT_DIRECTORY_KEY);
- if (objectDirEnv != null)
- objectdir = new File(objectDirEnv);
- else
- objectdir = null;
-
- File[] altobjectdirs;
- String altObjectDirEnv = SystemReader.getInstance().getenv(Constants.GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY);
- if (altObjectDirEnv != null) {
- String[] parserdAltObjectDirEnv = altObjectDirEnv.split(File.pathSeparator);
- altobjectdirs = new File[parserdAltObjectDirEnv.length];
- for (int i = 0; i < parserdAltObjectDirEnv.length; i++)
- altobjectdirs[i] = new File(parserdAltObjectDirEnv[i]);
- } else
- altobjectdirs = null;
-
- if (gitdir == null || !gitdir.isDirectory()) {
+ RepositoryBuilder rb = new RepositoryBuilder() //
+ .setGitDir(gitdir) //
+ .readEnvironment() //
+ .findGitDir();
+ if (rb.getGitDir() == null) {
writer.println(CLIText.get().cantFindGitDirectory);
writer.flush();
System.exit(1);
}
- cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir);
+
+ cmd.init(rb.build(), null);
} else {
cmd.init(null, gitdir);
}
@@ -224,27 +185,6 @@ public class Main {
}
}
- private static File findGitDir() {
- Set<String> ceilingDirectories = new HashSet<String>();
- String ceilingDirectoriesVar = SystemReader.getInstance().getenv(
- Constants.GIT_CEILING_DIRECTORIES_KEY);
- if (ceilingDirectoriesVar != null) {
- ceilingDirectories.addAll(Arrays.asList(ceilingDirectoriesVar
- .split(File.pathSeparator)));
- }
- File current = new File("").getAbsoluteFile();
- while (current != null) {
- final File gitDir = new File(current, Constants.DOT_GIT);
- if (gitDir.isDirectory())
- return gitDir;
- current = current.getParentFile();
- if (current != null
- && ceilingDirectories.contains(current.getPath()))
- break;
- }
- return null;
- }
-
private static boolean installConsole() {
try {
install("org.eclipse.jgit.console.ConsoleAuthenticator");
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
index 09a9f2b580..7a27617220 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
@@ -47,9 +47,10 @@ package org.eclipse.jgit.pgm;
import java.io.File;
import java.text.MessageFormat;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.RepositoryCache.FileKey;
+import org.eclipse.jgit.util.FS;
import org.kohsuke.args4j.Argument;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
@Command(common = false, usage = "usage_ServerSideBackendForJgitPush")
class ReceivePack extends TextBuiltin {
@@ -65,11 +66,14 @@ class ReceivePack extends TextBuiltin {
protected void run() throws Exception {
final org.eclipse.jgit.transport.ReceivePack rp;
- if (new File(dstGitdir, Constants.DOT_GIT).isDirectory())
- dstGitdir = new File(dstGitdir, Constants.DOT_GIT);
- db = new Repository(dstGitdir);
- if (!db.getObjectsDirectory().isDirectory())
- throw die(MessageFormat.format(CLIText.get().notAGitRepository, dstGitdir.getPath()));
+ try {
+ FileKey key = FileKey.lenient(dstGitdir, FS.DETECTED);
+ db = key.open(true /* must exist */);
+ } catch (RepositoryNotFoundException notFound) {
+ throw die(MessageFormat.format(CLIText.get().notAGitRepository,
+ dstGitdir.getPath()));
+ }
+
rp = new org.eclipse.jgit.transport.ReceivePack(db);
rp.receive(System.in, System.out, System.err);
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
index 1b8711dc9d..9f577ff05e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
@@ -67,9 +67,9 @@ class Rm extends TextBuiltin {
@Override
protected void run() throws Exception {
- root = db.getWorkDir();
+ root = db.getWorkTree();
- final DirCache dirc = DirCache.lock(db);
+ final DirCache dirc = db.lockDirCache();
final DirCacheBuilder edit = dirc.builder();
final TreeWalk walk = new TreeWalk(db);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
index 63d26eacae..c798950a2e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
@@ -49,13 +49,12 @@ package org.eclipse.jgit.pgm;
import java.text.MessageFormat;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.PersonIdent;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_CreateATag")
class Tag extends TextBuiltin {
@@ -86,9 +85,7 @@ class Tag extends TextBuiltin {
, tagName.substring(Constants.R_TAGS.length())));
}
- final ObjectLoader ldr = db.openObject(object);
- if (ldr == null)
- throw new MissingObjectException(object, "any");
+ final ObjectLoader ldr = db.open(object);
org.eclipse.jgit.lib.Tag tag = new org.eclipse.jgit.lib.Tag(db);
tag.setObjId(object);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 52d2488f70..d4e2bcec76 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -47,10 +47,11 @@ package org.eclipse.jgit.pgm;
import java.io.File;
import java.text.MessageFormat;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.RepositoryCache.FileKey;
+import org.eclipse.jgit.util.FS;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Repository;
@Command(common = false, usage = "usage_ServerSideBackendForJgitFetch")
class UploadPack extends TextBuiltin {
@@ -67,16 +68,19 @@ class UploadPack extends TextBuiltin {
@Override
protected void run() throws Exception {
- final org.eclipse.jgit.transport.UploadPack rp;
+ final org.eclipse.jgit.transport.UploadPack up;
- if (new File(srcGitdir, Constants.DOT_GIT).isDirectory())
- srcGitdir = new File(srcGitdir, Constants.DOT_GIT);
- db = new Repository(srcGitdir);
- if (!db.getObjectsDirectory().isDirectory())
- throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath()));
- rp = new org.eclipse.jgit.transport.UploadPack(db);
+ try {
+ FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
+ db = key.open(true /* must exist */);
+ } catch (RepositoryNotFoundException notFound) {
+ throw die(MessageFormat.format(CLIText.get().notAGitRepository,
+ srcGitdir.getPath()));
+ }
+
+ up = new org.eclipse.jgit.transport.UploadPack(db);
if (0 <= timeout)
- rp.setTimeout(timeout);
- rp.upload(System.in, System.out, System.err);
+ up.setTimeout(timeout);
+ up.upload(System.in, System.out, System.err);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java
index d772ffe23f..709b45a17b 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java
@@ -54,7 +54,7 @@ import org.eclipse.jgit.pgm.TextBuiltin;
class MakeCacheTree extends TextBuiltin {
@Override
protected void run() throws Exception {
- final DirCache cache = DirCache.read(db);
+ final DirCache cache = db.readDirCache();
final DirCacheTree tree = cache.getCacheTree(true);
show(tree);
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java
index 2a1079b313..0ca050880e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java
@@ -46,7 +46,6 @@ package org.eclipse.jgit.pgm.debug;
import java.text.MessageFormat;
-import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.pgm.CLIText;
import org.eclipse.jgit.pgm.TextBuiltin;
@@ -56,7 +55,7 @@ class ReadDirCache extends TextBuiltin {
final int cnt = 100;
final long start = System.currentTimeMillis();
for (int i = 0; i < cnt; i++)
- DirCache.read(db);
+ db.readDirCache();
final long end = System.currentTimeMillis();
out.print(" ");
out.println(MessageFormat.format(CLIText.get().averageMSPerRead, (end - start) / cnt));
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
index 1681dbc96e..5b75c1b5c5 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
@@ -62,7 +62,6 @@ import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.ObjectWritingException;
import org.eclipse.jgit.lib.Commit;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.LockFile;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.ObjectWriter;
@@ -76,6 +75,7 @@ import org.eclipse.jgit.lib.Tree;
import org.eclipse.jgit.pgm.CLIText;
import org.eclipse.jgit.pgm.TextBuiltin;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.file.LockFile;
/**
* Recreates a repository from another one's commit graph.
@@ -297,6 +297,7 @@ class RebuildCommitGraph extends TextBuiltin {
name, id));
}
} finally {
+ rw.release();
br.close();
}
return refs;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java
index 09796edb30..c49aefbf2f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java
@@ -54,7 +54,7 @@ import org.eclipse.jgit.pgm.TextBuiltin;
class ShowCacheTree extends TextBuiltin {
@Override
protected void run() throws Exception {
- final DirCache cache = DirCache.read(db);
+ final DirCache cache = db.readDirCache();
final DirCacheTree tree = cache.getCacheTree(false);
if (tree == null)
throw die(CLIText.get().noTREESectionInIndex);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java
index 854596c97b..a94d37ff87 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowDirCache.java
@@ -59,7 +59,7 @@ class ShowDirCache extends TextBuiltin {
final SimpleDateFormat fmt;
fmt = new SimpleDateFormat("yyyyMMdd,HHmmss.SSS");
- final DirCache cache = DirCache.read(db);
+ final DirCache cache = db.readDirCache();
for (int i = 0; i < cache.getEntryCount(); i++) {
final DirCacheEntry ent = cache.getEntry(i);
final FileMode mode = FileMode.fromBits(ent.getRawMode());
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
new file mode 100644
index 0000000000..1718ef30f2
--- /dev/null
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.pgm.debug;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.InflaterInputStream;
+
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException;
+import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ObjectReader;
+import org.eclipse.jgit.pgm.TextBuiltin;
+import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.pack.BinaryDelta;
+import org.eclipse.jgit.storage.pack.ObjectReuseAsIs;
+import org.eclipse.jgit.storage.pack.ObjectToPack;
+import org.eclipse.jgit.storage.pack.PackOutputStream;
+import org.eclipse.jgit.storage.pack.PackWriter;
+import org.eclipse.jgit.storage.pack.StoredObjectRepresentation;
+import org.eclipse.jgit.util.TemporaryBuffer;
+import org.kohsuke.args4j.Argument;
+
+class ShowPackDelta extends TextBuiltin {
+ @Argument(index = 0)
+ private ObjectId objectId;
+
+ @Override
+ protected void run() throws Exception {
+ ObjectReader reader = db.newObjectReader();
+ RevObject obj = new RevWalk(reader).parseAny(objectId);
+ byte[] delta = getDelta(reader, obj);
+
+ // We're crossing our fingers that this will be a delta. Double
+ // check the size field in the header, it should match.
+ //
+ long size = reader.getObjectSize(obj, obj.getType());
+ try {
+ if (BinaryDelta.getResultSize(delta) != size)
+ throw die("Object " + obj.name() + " is not a delta");
+ } catch (ArrayIndexOutOfBoundsException bad) {
+ throw die("Object " + obj.name() + " is not a delta");
+ }
+
+ out.println(BinaryDelta.format(delta));
+ }
+
+ private byte[] getDelta(ObjectReader reader, RevObject obj)
+ throws IOException, MissingObjectException,
+ StoredObjectRepresentationNotAvailableException {
+ ObjectReuseAsIs asis = (ObjectReuseAsIs) reader;
+ ObjectToPack target = asis.newObjectToPack(obj);
+
+ PackWriter pw = new PackWriter(reader) {
+ @Override
+ public void select(ObjectToPack otp, StoredObjectRepresentation next) {
+ otp.select(next);
+ }
+ };
+
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ asis.selectObjectRepresentation(pw, target);
+ asis.copyObjectAsIs(new PackOutputStream(NullProgressMonitor.INSTANCE,
+ buf, pw), target);
+
+ // At this point the object header has no delta information,
+ // because it was output as though it were a whole object.
+ // Skip over the header and inflate.
+ //
+ byte[] bufArray = buf.toByteArray();
+ int ptr = 0;
+ while ((bufArray[ptr] & 0x80) != 0)
+ ptr++;
+ ptr++;
+
+ TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(bufArray.length);
+ InflaterInputStream inf = new InflaterInputStream(
+ new ByteArrayInputStream(bufArray, ptr, bufArray.length));
+ raw.copy(inf);
+ inf.close();
+ return raw.toByteArray();
+ }
+}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java
index cee5966a03..142dbeecc8 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java
@@ -51,7 +51,7 @@ import org.eclipse.jgit.pgm.TextBuiltin;
class WriteDirCache extends TextBuiltin {
@Override
protected void run() throws Exception {
- final DirCache cache = DirCache.read(db);
+ final DirCache cache = db.readDirCache();
if (!cache.lock())
throw die(CLIText.get().failedToLockIndex);
cache.read();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java
index e13bb1f136..a99e0abca2 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java
@@ -51,7 +51,6 @@ import java.text.MessageFormat;
import org.eclipse.jgit.iplog.IpLogGenerator;
import org.eclipse.jgit.iplog.SimpleCookieManager;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.LockFile;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.pgm.CLIText;
import org.eclipse.jgit.pgm.Command;
@@ -59,6 +58,7 @@ import org.eclipse.jgit.pgm.TextBuiltin;
import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.file.LockFile;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java
index 4f0e338e8d..b563f07910 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java
@@ -91,7 +91,7 @@ class Ipzilla extends TextBuiltin {
}
if (output == null)
- output = new File(db.getWorkDir(), IpLogMeta.IPLOG_CONFIG_FILE);
+ output = new File(db.getWorkTree(), IpLogMeta.IPLOG_CONFIG_FILE);
IpLogMeta meta = new IpLogMeta();
meta.syncCQs(output, ipzilla, username, password);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
index 2043ac2090..01981600dd 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
@@ -59,7 +59,7 @@ import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.WindowCursor;
+import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.pgm.CLIText;
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
import org.eclipse.jgit.treewalk.CanonicalTreeParser;
@@ -121,9 +121,9 @@ public class AbstractTreeIteratorHandler extends
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
final CanonicalTreeParser p = new CanonicalTreeParser();
- final WindowCursor curs = new WindowCursor();
+ final ObjectReader curs = clp.getRepository().newObjectReader();
try {
- p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs);
+ p.reset(curs, clp.getRevWalk().parseTree(id));
} catch (MissingObjectException e) {
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
} catch (IncorrectObjectTypeException e) {