aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-03-19 10:26:07 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-03-19 10:26:27 +0100
commitd081ff78f7bbdffea3334aaea207125adeb6819b (patch)
treeae0a6ac243c79244aa308743977cfdbb25d3b23c /org.eclipse.jgit.junit
parentf6597971991e3350df568b0cde05c014dcd69c47 (diff)
parent41643dcb79a52e9fac03b77d40d6b33df13f034b (diff)
downloadjgit-d081ff78f7bbdffea3334aaea207125adeb6819b.tar.gz
jgit-d081ff78f7bbdffea3334aaea207125adeb6819b.zip
Merge branch 'master' into next
* master: (27 commits) Optimize RevWalkUtils.findBranchesReachableFrom() Introduce getMergedInto(RevCommit commit, Collection<Ref> refs) Skip detecting content renames for large files Remove unused API problem filters Document http options supported by JGit HTTP cookies: do tilde expansion on http.cookieFile Prepare 5.12.0-SNAPSHOT builds Update Orbit to R20210223232630 Prepare 5.11.1-SNAPSHOT builds JGit v5.11.0.202103091610-r Manually set status of jmh dependencies Update DEPENDENCIES report for 5.11.0 Add dependency to dash-licenses PackFile: Add id + ext based constructors GC: deleteOrphans: Use PackFile PackExt: Convert to Enum Restore preserved packs during missing object seeks Pack: Replace extensions bitset with bitmapIdx PackFile PackDirectory: Use PackFile to ensure we find preserved packs GC: Use PackFile to de-dup logic ... Change-Id: I2326d4d728fbde3090a5b87b0e273db46e0c5f62 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java12
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java16
2 files changed, 18 insertions, 10 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
index 64556acc1c..5622108dcd 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
@@ -25,6 +25,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.file.Path;
import java.time.Instant;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -39,6 +40,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -386,6 +388,16 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
}
/**
+ * Get all Refs
+ *
+ * @return list of refs
+ * @throws IOException
+ */
+ public List<Ref> getRefs() throws IOException {
+ return db.getRefDatabase().getRefs();
+ }
+
+ /**
* Checkout a branch
*
* @param branchName
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index e3eb2c5367..0232156a49 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -44,7 +44,9 @@ import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.internal.storage.file.LockFile;
import org.eclipse.jgit.internal.storage.file.ObjectDirectory;
import org.eclipse.jgit.internal.storage.file.Pack;
+import org.eclipse.jgit.internal.storage.file.PackFile;
import org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry;
+import org.eclipse.jgit.internal.storage.pack.PackExt;
import org.eclipse.jgit.internal.storage.pack.PackWriter;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
@@ -906,23 +908,22 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
ObjectDirectory odb = (ObjectDirectory) db.getObjectDatabase();
NullProgressMonitor m = NullProgressMonitor.INSTANCE;
- final File pack, idx;
+ final PackFile pack, idx;
try (PackWriter pw = new PackWriter(db)) {
Set<ObjectId> all = new HashSet<>();
for (Ref r : db.getRefDatabase().getRefs())
all.add(r.getObjectId());
pw.preparePack(m, all, PackWriter.NONE);
- final ObjectId name = pw.computeName();
-
- pack = nameFor(odb, name, ".pack");
+ pack = new PackFile(odb.getPackDirectory(), pw.computeName(),
+ PackExt.PACK);
try (OutputStream out =
new BufferedOutputStream(new FileOutputStream(pack))) {
pw.writePack(m, m, out);
}
pack.setReadOnly();
- idx = nameFor(odb, name, ".idx");
+ idx = pack.create(PackExt.INDEX);
try (OutputStream out =
new BufferedOutputStream(new FileOutputStream(idx))) {
pw.writeIndex(out);
@@ -960,11 +961,6 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
}
}
- private static File nameFor(ObjectDirectory odb, ObjectId name, String t) {
- File packdir = odb.getPackDirectory();
- return new File(packdir, "pack-" + name.name() + t);
- }
-
private void writeFile(File p, byte[] bin) throws IOException,
ObjectWritingException {
final LockFile lck = new LockFile(p);